LIS 525 - Active Server Pages

Active Server Pages are dynamic Web pages (with the extension .asp) that use Microsoft ActiveX scripting code. ASP pages are similar to CGI scripts, but are specific to Windows servers. An ASP page can be created by inserting script commands into HTML with a text editor. The default scripting language for ASP is VBScript. Scripts in other languages, such as JScript, can also be inserted, by means of the HTML script tag with the runat attribute equal to "Server".

An example of a simple ASP page is as follows:

    <% For i = 3 To 7 %> 
    <FONT SIZE=<% = i %>> 
    Hello World!<BR> 
    <% Next %> 
If you used a browser to access this file on a Windows server, you should see the following:
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
On the other hand, if you access the same file on the University's Unix server, which uses Apache, results will vary. The MIME type assigned to the file by the server is application/x-asap. Netscape Navigator is likely not to know what to do with this type of file and to prompt you for an application to handle it. If you choose the default application, the file may be opened in an editor, such as FrontPage. If you choose Navigator itself as the application, Navigator will launch infinite instances of itself, and will have to be shut down with the Task Manager. Firefox will allow you only to save the file to disk. Internet Explorer will prompt you for whether you want to open it, save it, or cancel; opening it will open it in the default application, such as FrontPage. The prompt in Opera is similar, but also allows you to open with other than the default application. If you choose to open it with Opera, Opera will display the HTML code.

Here is an example of a simple ASP page that includes server-side JScript:

    <% Call PrintDate %>
    function PrintDate() 
      var x
      x = new Date() 
When you access this file on a Windows server, you should see something like the following (except with the current date and time):
Fri, 20 Apr 2007 14:20:49 UTC

For information on using Microsoft FrontPage to create ASP files to provide a simple Web interface for a Microsoft Access database, see LIS 558 - Active Server Pages.

For More Information


Last updated October 31, 2007.
This page maintained by Prof. Tim Craven
E-mail (text/plain only):
Faculty of Information and Media Studies
University of Western Ontario,
London, Ontario
Canada, N6A 5B7