The last section served to introduce you to client-side scripting: how to include scripting code in the web pages that are viewed by your users. Now you will learn how to bring the power of scripting to the server and harness it to dynamically create HTML in reaction to user requests.
As you will recall from the last chapter, when the browser makes a request for a file ending with the .ASP file extension, IIS knows to bring ASP.DLL into play to interpret the ASP code in the file. Once interpreted, the results of this code are placed into the document, which is a simple HTML document before it is sent to the user.
How does ASP.DLL know which code to interpret?
The answer to this question is the key to executing code on the
server. ASP.DLL interprets all code in a file
(with the .ASP file extension) that's
as being ASP code. (There is another way to delineate server-side code that I'll cover in
a moment.) Example 2.2 shows an active server page
named ExampleChap2.ASP, with the VBScript code
that will be interpreted by ASP.DLL in bold.
Example 2.2. ExampleChap2.ASP
<HTML> <HEAD><TITLE>Example</TITLE></HEAD> <BODY>
<% ' Construct a greeting string with a salutation and the ' current time on the server (retrieved from the Time( ) ' function) and then display that in the HTML sent to the ' client. strGreetingMsg = "Hello. It is now " & Time( ) & _ " on the server." Response.Write strGreetingMsg %></BODY> </HTML>
When a user requests ExampleChap2.ASP ...