Flylib.com

Books Software

 
 
 

Active Server Pages

Active Server Pages

Another milestone technology—one discussed extensively in this book—is Active Server Pages, or ASP. In many ways, ASP is the most exciting of all the new Internet technologies because it allows you to create great, platform-independent content that can be used in any browser. Or, if you want to take maximum advantage of platform-specific technologies such as Dynamic HTML, you can create ASP pages that speak directly to Internet Explorer 4.0.

At its most fundamental, ASP is scripting done on the server. This scripting code is evaluated dynamically when the page is requested , and the resulting HTML is passed to the calling browser. Consider the code in Listing 1-6, which uses ASP to generate six successive lines of text that get increasingly larger.

Listing 1-6. An ASP Web page.


<%@SCRIPT LANGUAGE="VBSCRIPT"%> <HTML> <HEAD> <META

NAME

="GENERATOR" Content="Microsoft Developer Studio"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>ASP Example</TITLE> </HEAD> <BODY BGCOLOR="WHITE"> <%For x = 1 to 6%> <FONT FACE="ARIAL" SIZE=<%=x%>> ActiveX Is Cool! </FONT> <P> <%Next%> </BODY> </HTML>

The sample code includes a <SCRIPT> tag, but notice that percent signs appear inside the brackets. This syntax indicates that the code is to be executed on the server before the page is downloaded to the client. In fact, notice the percent signs that surround all the code in the page. This code is all evaluated before the browser receives the page. The resulting HTML code looks like this:

<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Developer Studio"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>ASP Example</TITLE> </HEAD> <BODY BGCOLOR="WHITE"> <FONT FACE="ARIAL" SIZE=1> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=2> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=3> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=4> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=5> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=6> ActiveX Is Cool! </FONT> <P> </BODY> </HTML>

In the resulting HTML lies the beauty of Active Server Pages. ASP output can be limited strictly to HTML—understandable by any browser! This makes ASP an ideal choice for applications that must run on the Internet, where any browser can view a page. ASP is not limited to the lowest common denominator, however, and you can freely add client script, ActiveX controls, and Dynamic HTML to the output of ASP. ASP pages are therefore as flexible as you want them to be.

Web Services

The heart and soul of any good Web site is the back-end server. The Web server can provide static Web pages in the form of HTML documents, but it can also execute applications that significantly enhance the content of a site. The idea of executing content on a Web server is not new. In past implementations , a Web server used the Common Gateway Interface, or CGI, to execute content. CGI is a technology that allows a Web server to start an executable and use that process to accomplish tasks such as sending e-mail. CGI applications add much-needed functionality to Web sites, but they are typically slow because a CGI application runs as a separate process. Since the Web server and the CGI application must exchange data across processes, communication between them is slowed down considerably.