How ASP works:
- A client browser requests an ASP page from the server
-
The server passes the request to ASP.DLL which reads the global.asa
file for further instructions
-
ASP includes any files specified by the scripts
-
The scripting engines process the asp scripts and send the
feed back to ASP
-
ASP translates the feedback from the scripting engines into
HTML code.
- The interpreted contents are send to the browser as HTML data.
Execution order
ASP will execute the scripts in different order,
depending on the language and syntax:
- global.asa
-
server-side includes
-
Javascript tagged with <script> tags
-
HTML together with scripts tagged within <% %> delimiters
-
VBscript tagged within <script> tags
Try the following examples. Although we write "one two three...
ten" in order in code, but the script is executed in different
order and those number displayed in a different way. Run the
following example, you will have better feeling of execution orders.
Example: Order of execution
<HTML>
<head>
<title>testing the order of execution</title>
</head>
<body>
One <%="Two"%> Three
<script runat=server language =vbscript>
Response.Write "Four "
</script>
Five <%="Six"%> Seven
<Script runat=server language =vbscript>
Response.write "Eight "
</script>
Nine <%="Ten"%>
</body>
</html>
Example2: using jscript
This one displays number in a different order from the above VBscript
example.
<HTML>
<head>
<title>testing the order of execution</title>
</head>
<body>
One <%="Two "%> Three
<script runat=server language=vbscript>
Response.Write "Four "
</script>
Five <%="Six"%> Seven
<script runat=server language=jscript>
<!--
document.write("Eight ");
//-->
</script>
Nine <%=" Ten"%>
</body>
</html>
|