Overview:

Microsoft Active Server Pages

Tim Heidinger, Pandelis Tiritas
University of California, Berkeley
Undergraduate Affairs

Overview

Microsoft® Active Server Pages (ASP) is a server-side scripting environment that you can use to create and run dynamic, interactive, high-performance Web server applications. When your scripts run on the server rather than on the client, your Web server does all the work involved in generating the Hypertext Markup Language (HTML) pages that you send to browsers.

Requirements

Active Server Pages is a feature of and can be used with the following Web servers:

A third party company is developing ASP support for a number of other Web servers. (Chili!Soft http://www.chilisoft.net/)

All the Web servers that support Active Server Pages require Windows NT or Windows 95, and as a result such a machine running one of the two operating systems is required to run Active Server Pages.

Database Connectivity

The most common method to access data with ASP scripts is to use the ASP Database Access component. The Database Access component uses ADO (ActiveXÔ Data Objects) to access information stored in a database or other tabular data structure. Any data source that has an ODBC driver can be accessed with ADO. The features supported for each data source depend on the capabilities of individual ODBC drivers. There are drivers for most database back-ends and desktop formats, including Oracle, MS SQL Server, Sybase, FoxPro, Paradox and dBase.

The ability to extend ASP with ActiveX controls opens some interesting possibilities for other methods of accessing data sources. For example, one could create a Visual FoxPro program that does all the data access using VFPās extremely fast database engine, save it as an ActiveX component and use it from within ASP to run queries against a FoxPro database.

Development Environment

Microsoft offers a product called Visual Interdev (Wareforce: License ~ $37, CD $17, Docs: On-line) , which is a visual integrated development environment for building ASP applications. Visual Interdev has the following features:


Pros

You can use ASP to include executable scripts directly in HTML files. HTML development and scripting development become the same process, enabling you to focus directly on the look and feel of your Web site, weaving dynamic elements into your pages as appropriate. ASP applications are:

ASP applications are easy to develop because you use ASP scripting to develop them. With ASP scripting, you can use any scripting language for which you provide the appropriate scripting engine. ASP supplies scripting engines for Microsoft® Visual Basic® Scripting Edition (VBScript) and Javascript. You can incorporate sophisticated functionality using ActiveX server to process data and generate useful information.

Unlike the limited macro-like languages found in other products, ASP can use real scripting languages such as VBScript and Javascript, which offer the programmer a lot of power. The ability to choose between different languages and the popularity of the two included by default increases the chance that you already know how to program in ASP.

ASP solves the notorious problem of "keeping state" by sending a session id in the form of an HTTP cookie each time a browser calls an ASP application for the first time. The interface allows programmers to maintain session-scope variables (including data-bound objects) that are maintained between successive hits.

ASP-generated content is compatible with standard Web browsers.

Cons

The Future

Microsoft IIS 4.0, currently in beta 3 will add new features to Active Server Pages that will make it even easier to deploy reliable and scalable multi-user Web based applications:

 

ASP Code Sample

The following code sample opens a connections to an ODBC data source called ADOSamples, creates a record set based on a SELECT statement, loops through the fields to display field names, and then loops through each record, displaying all fields in an HTML table. Finally it closes the record set and the connection, and exits. Notice how ADO allows looping through a record set without prior knowledge of field names by using the fieldās index number. Alternatively, the code could specify the field name in the form RecordSetName("FieldName").

Text in bold type is VBScript code. Text following a "ā" is a comment.

<HTML>
<HEAD>
<TITLE>ActiveX Data Object (ADO)</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<H3>ActiveX Data Object (ADO)</H3>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "ADOSamples" 'ADOSamples is the name of ODBC the Data Source
Set RS = Conn.Execute("SELECT * FROM Orders") 'Create record set
%>

<P>
<TABLE BORDER=1>
<TR>
<% For i = 0 to RS.Fields.Count - 1 'Loop through fields%>
<TD><B><% = RS(i).Name 'Display field name%></B></TD>
<% Next %>
</TR>
<% Do While Not RS.EOF 'Loop through each record%>
<TR>
<% For i = 0 to RS.Fields.Count - 1 %>
<TD VALIGN=TOP><% = RS(i) %></TD>
<% Next %>
</TR>
<%
RS.MoveNext
Loop
RS.Close
Conn.Close
%>

</TABLE>
<BR>
<BR>
<!--#include virtual="/ASPSamp/Samples/srcform.inc"-->
</BODY>
</HTML>

 

Undergraduate Affairs ASP Applications

Student Registration Status on the Web

http://registrar.berkeley.edu:4202/regweb.html

Displays registration status for any UCB student, replacing the registration sticker on student id cards. Functionality includes password protection for restricted display options, limiting restricted options to ".berkeley.edu". (VisualFoxPro and Oracle)

Career Center

http://career.berkeley.edu/

Calendar and event applications. Staff data-entry pages to update the database. Using ASPMail to provide SMTP mail functionality to an application that allow students to subscribe to constituent groups. (MS SQL Server) Developed jointly with the Computer Assistance Program (http://www-oms.berkeley.edu/cap/).

UGA Report Factory

Currently underdevelopment in pilot status. Provides authorized staff with a web-based reporting tool that generates HTML reports, formatted 3 up address labels, and simple e-mail interface. (Oracle)

Kerberos Authentication

We are currently attempting to develop a way to easily add Kerberos authentication to ASP applications.

 

URLs