Name: Zhumei Wang, Carol Wang
Prof.: Dr. Zaiane
Course: CMPUT499
Date: Mar 1st 2001
Project: ASP Presentation

                                                Report for Active Sever Page (ASP) Presentation

Introduction

We are going to introduce Active Sever Page (ASP), one of the Microsoft products, in this report.
The topics we will cover includes: what is ASP; what are the advantages of using ASP; how does ASP work; ASP structure and syntax illustrated with an example; programming web database with ASP; and finally the next generation web services framework, ASP+.

What is ASP

Active Server Page (ASP) is a Web Server application development technology, designed to make it easier
for Web application developers to created sophisticated Web applications (S.Hettihewa 1998, p.8).

Here's the official word from the Microsoft site: "Active Server Page is an open, compile free application
environment in which you can combine HTMl, scripts, and reusable ActiveX server components to create
dynamic and powerful Web based business solutions. Active Sever Page enables server side scripting for
IIS with native support for both VBScript and Jscript."

ASP is an "open technology framework", which means that we don't need to use Microsoft product to
create code in it. You can create ASP using whatever language you want, but VBScript is still the most common choice.

Advantages of ASP

There are many good features that make ASP one of the most popular web development technologies available.
Here are some of the benefits according to Hettihewa:

ASP server-generated pages which can call other programs to do things like access database, generate different
pages to different web browsers. Common Gateway Interface (CGI) is one of the most commonly used technology for generating web pages on server side written in any language. Anything we can do with CGI, we can
do it in ASP just as efficiently. And ASP is even more efficient because each time the CGI application is executed, a new process has to be created on the server which can be quite resource intensive for the server especially when the server is accessed many times a day. While in ASP, it runs as a service and it can take advantage of multithread
architecture.

How Does ASP Work

All ASP code is executed on the Web server. This means that each time a user sends a request to the server, the ASP code is executed and the HTML page is generated on the fly and sent back to the browser. The client requests an ASP page by sending an HTTP Get or Post Request to the server. If the server cannot find the file then it responds with the HTTP 404 Not Found message. If the file is found, it will be recognized as an Active Server Page because of its .asp extension and sent to the ASP Scripting engine to be parsed.
The Scripting Host is located in asp.dll. If this is the first ASP page the client has requested, it will check global.asa for anything to do before it gets to the requested page. Otherwise, the host executes all the server-side scripting code in the page as delimited by either <% ... %> or <SCRIPT RUNAT=SERVER> ... </SCRIPT> tags. Once this has been done, the engine passes back one of three things: an error page, an object moved status code, or an HTML page. If either an error page or a correctly-formed HTML page is passed back, it is
then displayed. If the ASP page contained a call to Response.Redirect, the server will pass back to the client the HTTP code 302 telling it that the page requested has moved temporarily (ASP101, Brick Mountain, 2000).

ASP Structure and Syntax

An ASP application is no more than a collection of Web pages with additional scripting commands executed on the
server. An ASP application primarily consists of the following elements:

The only difference between a typical Web page and an ASP application is the presence of ASP script delimiters.
The example in Listing 1 adapted from Hettihewa illustrates a typical ASP application with ASP script delimiters.
Figure 1 shows the output of that ASP application (S. Hettihewa 1998, p. 35).

Listing 1: Components of a Typical ASP application

    <%@ LANGUAGE="VBSCRIPT" %>
      <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

       Sub SayHello ()
           Response.Write("<H1>Hello! Today's date is " &Date &" </H1>")
       End Sub

      </SCRIPT>

     <HTML>
       <HEAD>
           <TITLE> Syntax of ASP Applications </TITLE>
       </HEAD>
       <BODY  bgcolor="white">
           <!-- insert HTML here -->

           <%= "<H2>This line of text is displayed as output </H2>" %>

           <%
              Call SayHello ()
              Response.write("<HR>")
          %>
        </BODY>
        </HTML>

FIGURE 1. The output of the ASP application in listing 1

ASP has three delimiters, we have the first two in our example.
1. "<%" and "%>" is used to separate blocks of ASP code from the rest of a web page.
     The server assume that anything between the delimiters is code and will try to execute it.
      So don't put HTML there. In the first line, <%@ Language=VBScript> specifies the script
      language to use. If you don't specify the script language, the default script language is VBscript.
2.  "<%= " and "%>" is used to display the value of an expression or variable.
      In our example, we have <%= "<H2>This line of text is displayed as output </H2>" %> to output the string in font <H2>.
3.   "<Script>" and "</Script>" delimiter is used to define the ASP Script blocks and specifying the scripting
       language if you do not want to use VBscript.

ASP subroutines can be enclosed between the delimiters <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>.
and </SCRIPT >.  The subroutine SayHello defined in this section is executed by ASP statement Call SayHello() in the BODY of the code.

In our example, we used Reponse.write() method in Response object to write the output to the browser.
The Response object is one of the five build-in objects in ASP. Here is the scoop on these objects from the Microsoft site:

Each of these objects has a collections of methods and one or more properties, each called with the usual object-orientaion-style code [value=Object.Property or value= Object.Method()].

Programming Web Database with ASP

ASP applications interact with database by using ActiveX Data Objects (ADO).  ADO is a group of objects designed to provide a simple program interface to database. Here are the basic steps for using ADO according to Hettihewa (S. Hettihewa 1998, p.254):

Step 1: Create an Instance of the Connection Object.
    The first step for interfacing with a database is creating an instance of the Connection object. This is done by
    using the following ASP statement:

    Set DatabaseConnection = Server.CreateObject("AD0DB.Connection")

Step 2: Open the connection to the Database
    After the Connection object is created, we need to specify which database we want to work with by using the
   Open method and specifying the DSN. The following statement opens the file DSN mydata.dsn:

    DatabaseConnection.open "FILEDSN=mydata.dsn"

Step 3: Issue SQL Commands to the Database
    After establishing a connection with a database, the Execute method of the Connection object is used to issue
    SQL commands. The SQL statements can be used to modify the contents of database. The syntax of the
    Execute method of the Connection object is as follows:

    DatabaseConnection.Execute "<SQLStatementGoesHere>" where SQLStatementGoesHere is any legal SQL
    statement.

Step 4: Close the Data Connection
    The database connection should be closed after being accessed immediately to make the efficient use of the
    database resources and failure to do so might cause the ASP subcomponent to crash and stop parsing any more
    ASP applications. This is the syntax for closing a database connection:

    DatabaseConnection.Close
    Set DatabaseConnection = Nothing

For more information about ASP web database programming, please refer to the web site
"http://cpcug.org/user/houser/asp/" (W.Hourse, J.Hart).

The next generation: ASP+

Although we can obtain so many benefits from using ASP , it still has some drawbacks. One of the main
drawbacks is that ASP is not object-oriented. This brings us to the next generation web services framework, ASP+. From the "outside" (as far as the developer is concerned) ASP+ appears to offer a very similar interface to ASP,
but the underlying structure of ASP+ is very different to ASP. It is almost entirely component based
and modularized, and every page, object, and HTML element you use can be a runtime component object.
This allows developers to build more powerful applications by accessing these component objects in a far more
granular and controlled manner.

Conclusion

Active Server page is revolutionizing the way Web applications are developed and it makes Server-side programming easier than the traditional CGI programming with languages like Perl or C. ASP simplifies the lives
of Web application developers and it can easily offer dynamic, compelling information to users browsing the site.
In sum, Active Server page is a powerful, easy to implement and one of the most exciting Web development technologies available today.
 

 
Works Cited


S. Hettihewa, Sams Teach Yourself Active Server Pages 2.0 in 21 days.
     1998 Sams Publishing, USA.

Web sites referenced:
http://www.asp101.com, ASP 101 - Active Server Pages 101
http://cpcug.org/user/houser/asp, W.Hourse, J.Hart, Developing Web Database Applications
     Using Active Server Pages (ASP), 2000.
http://hotwired.lycos.com/webmonkey/programming/asp, Web monkey, Programming ASP.