The Execute method calls a script enabled content file and processes it as if it were part of the calling script. The Execute method is similar to a procedure call in many programming languages.
Server.Execute( Path )
The Server.Execute method provides a way of dividing a complex application into individual modules. By employing the Server.Execute method, you can develop a library of .vbs files that you can call as needed. This approach is an alternative to server-side includes. The major difference is that you can dynamically call a script enabled file with Server.Execute.
After eMill processes the script enabled content file specified in the input parameter to Server.Execute, the response is returned to the calling script.
Collections and properties available to the executed file are:
If a file is included in the calling page with #include, the executed .asp will not see it. For example, you may have a subroutine in a file that is included in your calling page, but the executed .asp will not recognize the subroutine name. You must include the file in each executed .asp that requires the subroutine.
If either the calling or called .asp file contains a transaction directive, the status of the transaction will apply to the .asp file that contains the directive. For example, if ASP1 below calls ASP2 and the transaction is aborted while ASP2 is being processed, ASP2's OnTransactionAbort (if present) will be called. After ASP2 completes processing, ASP1's OnTransactionAbort (if present) will be called.
ASP1:
<%@ Transaction=Required %>
<%
Server.Execute ("ASP2.asp")
Sub OnTransactionAbort
Sub OnTransactionCommit
%>
ASP2.asp:
<%@ Transaction=Required %>
<%
Sub OnTransactionAbort
Sub OnTransactionCommit
%>
In the following example, the browser language determines which .asp file is executed. The output from these scripts on a US system is:
Company Name
Welcome to my website!
The output from these scripts on a German system is:
Company Name
Willkommen zu meinem website!
The output from these scripts on a Spanish system is:
Company Name
Recepción a mi website!
(Languages with multi-byte characters have not been included in this example because CodePage incompatibilities.)
Welcome.asp
<HTML>
<BODY>
<H1>Company Name</H1>
<%
AcceptLang = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
Lang = Left(AcceptLang, 2)
Server.Execute(Lang & "Welcome.asp")
%>
</BODY>
</HTML>
enWelcome.asp
<% Response.Write "Welcome to my website!" %>
deWelcome.asp
<% Response.Write "Willkommen zu meinem website!" %>
esWelcome.asp
<% Response.Write "Recepción a mi website!" %>