The actual interpretation of the web page by the ASP.DLL ISAPI filter is best explained by example. Example 1.1 shows a simple active server page, Sample.ASP. In this example, three pieces of server-side code, indicated in boldface, when executed on the server, create HTML that is sent to the client. This is a quick introduction. Don't worry if you don't understand exactly what is going on in this example; the details will be explained in Chapter 2.
Example 1.1. Sample.ASP, an Example of Processing Server-Side Script
<%@ LANGUAGE="VBSCRIPT" %>
<HTML> <HEAD> <TITLE>Sample ASP</TITLE> </HEAD> <BODY> Good afternoon.<BR> Welcome to the sample. It is now approximately<%=Time( )%>
at the server. Here are a couple of demonstrations:<BR><BR><BR> Some simple text formatting done using HTML:<BR> <FONT SIZE = 1>Hello Size 1</FONT><BR> <FONT SIZE = 2>Hello Size 2</FONT><BR> <FONT SIZE = 3>Hello Size 3</FONT><BR> <FONT SIZE = 4>Hello Size 4</FONT><BR> <FONT SIZE = 5>Hello Size 5</FONT><BR> <BR> The same text formatting using server-side code:<BR> <% For intCounter = 1 to 5 %> <FONT SIZE =<%=intCounter%>
> Hello Size<%=intCounter%>
</FONT><BR> <% Next %> <BR> </BODY> </HTML>
When the client receives the HTML result from the ASP script's execution, it resembles Figure 1.3.
If you were to view the HTML source behind this HTML, you would see the output in Example 1.2.
Example 1.2. Sample.HTM, the Output of Sample.ASP
<HTML> <HEAD> <TITLE>Sample ASP</TITLE> </HEAD> <BODY> Good afternoon.<BR> Welcome to the sample. It is now approximately 9:28:47 at the server. Here are a couple of demonstrations:<BR><BR><BR> Some simple text formatting done using HTML:<BR> <FONT SIZE = 1>Hello Size 1</FONT><BR> <FONT SIZE = 2>Hello Size 2</FONT><BR> <FONT SIZE = 3>Hello Size 3</FONT><BR> <FONT SIZE = 4>Hello Size 4</FONT><BR> <FONT SIZE = 5>Hello Size 5</FONT><BR> <BR> The same text formatting using server-side code:<BR> <FONT SIZE = 1>Hello Size 1</FONT><BR> <FONT SIZE = 2>Hello Size 2</FONT><BR> <FONT SIZE = 3>Hello Size 3</FONT><BR> <FONT SIZE = 4>Hello Size 4</FONT><BR> <FONT SIZE = 5>Hello Size 5</FONT><BR> <BR> </BODY> </HTML>
The server accepted the request, ASP.DLL interpreted and executed the server-side script and created HTML. The HTML is sent to the client, where it appears indistinguishable from straight HTML code.
As mentioned earlier, you will learn more about server-side scripting and how it works in Chapter 2.
Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.