• A Web server hosts information in the form of HTML files.
  • The Web server is usually passive and merely acts as an efficient interface between the Web browser and the information stored on the Web server.
  • Web pages are usually processed by the browser.


Static Web Page


  • Most Web servers can now host dynamic HTML content. Such Web  servers are known as active servers as they play an active role in creating Web pages in response to user requests.
  • The technology that enables Web servers to host dynamic data is  known as Active Server Pages.
  • Active Web servers store information in the form of ASP files.
  • ASP files are first preprocessed on the server by a special server-side program known as ASP.DLL.
  • This program processes the file from top to bottom and produces an  HTML file.
  • The client browser only receives HTML files. Hence ASPs are compatible with any browser running on any kind of operating system.
  • ASP files have the extension .asp.

What is an ASP?

An ASP file is a standard HTML file that can contain anything that an  HTML file can contain, including normal HTML tags, client-side scripts,  client-side ActiveX controls and Java applets.  It has certain additional features to distinguish it from HTML files:

  • Server-side scripts: It is this feature that makes Web pages dynamic.   ASP.DLL executes the scripts and develops the HTML file accordingly.
  • Built-in objects: These objects can be used to enhance scripts and  what they can do.
  • Server-side components: These components can be used to extend  the capabilities of Web pages and customize them as desired by Web  authors. ASPs also support user-developed components.
  • Database Connectivity: An Active Server Page can be used to connect to and exchange data with a database such as the Microsoft SQL Server  through a special set of objects known as the ActiveX Data Objects (ADO).

History of Active Server Pages

A number of technologies, notably the Common Gateway  Interface (CGI), have also tried to create dynamic HTML content in response to the information submitted by users.

Common Gateway Interface

CGI is a standard communication and processing mechanism between the requesting client browser, the gateway program  and the Web server.  The CGI programs form a standard interface between the client  browser and the Web server.   CGI programs support connectivity to databases that are  compliant with Open Database Connectivity (ODBC).  Each time a CGI program is requested by a user, a separate  instance of the program is created.  CGI programs are not scalable.

Internet Server Application Programming Interface (ISAPI)

  • ISAPI has been developed to overcome the shortcomings of CGI.
  • ISAPI scripts are implemented in the form of DLLs, which are loaded into the memory and execute in process with the Web server.
  • Each user request spawns a separate thread of execution within the same process space.
  • If an ISAPI program crashes, it can bring down the Web server.
  • ISAPI is implemented in the form of ISAPI applications or ISAPI filters.
  • Active Server Pages are implemented as an ISAPI filter. The ASP (ISAPI) filter ignores all Web pages except those with a .ASP extension.
  • The major reason for the popularity of ISAPI, especially for high traffic  Web servers, is scalability.

Applications of ASPs

  • Exchange information between HTML forms and a database.
  • Add hit counters to Web sites.
  • Create dynamic Web pages.
  • Modify the content of Web pages to suit the capabilities of  client browsers.
  • Link multiple Web pages together.
  • Track and collect information about the users visiting a site.
  • Read and write to files located on the client system.
  • Use customized ActiveX components.
  • Add advertisements to Web pages.

Elements of Active Server Pages



ASPs enhance Web pages through Active Scripting. Can use any scripting language as long as the scripting engine of that language is compatible with ActiveX scripting standards. By default, ASPs use VBScript as the server-side scripting language. If you use any other language then you have to declare the language explicitly using one of the following three methods:

  • Specify the default language using the Internet Service Manager


  • Specify the language using an Active Server Page directive.


  • Specify the language using Microsoft’s extended HTML


Scripts contained within the tag are independent of their location in the ASP and are always executed first. They are mainly used to write functions and procedures.  Generally, the Response.Write() is used to output the value of an expression within a script and the output directive is used to output the value of an expression contained directly within HTML code.



An object contains properties, methods and collections of values  and keys.

Some of the functions performed by the built-in objects of ASPs are listed below.

•  Server: The Server object enables users to access utility functions on the server.
•  Session: The Session object is used to store and retrieve information related to a particular user session.
• Application: The Application object is used to store and retrieve information related to a particular Web application.
•  Request: The Request object is used to access information sent by a client browser to the server.
•  Response: The Response object is used to send information  from the server to the client browser.
•  Scripting languages also contain some objects, which can be used in ASP scripts even though they are not actually included in ASP. A typical  example is that of the Dictionary object.


Objects can be explicitly destroyed during the course of the ASP by  changing the value of the object instance or by simply setting the value  to nothing.


  • ASP components can contain more than one object and are usually used to perform more specialized functions. Further they must be instantiated before they can be used.
  • Some of the major functions to which ASP components can be applied are listed below.
  • Content Rotator: This can be used to display the contents of a  Web page in a random manner.
  • Content Linking: This component is used to link together multiple HTML pages to ease navigation among them.
  • Permission Checker: This component is used to control the  access of Web surfers to certain Web pages.
  • Browser Capabilities: This component is used to assess the capabilities of Web browsers and display the Web page accordingly.
  • Ad Rotator: This component is used to control the frequency of appearance of different advertisements on a Web page.
  • Counters: This component is commonly used to count the  number of Web surfers who visit a particular Web site.
  • Page Counter: This is a specialized hit counter that is used to count the number of Web surfers who visit a specific Web page.
  • ActiveX Data Objects: These objects are used to store and retrieve data in a variety of databases on the server.

Getting Started With ASP

You will be using ASP with Internet Information Server on a  Windows NT platform.
Creating your own Web Site

•Start the Microsoft Management Console.
•Right-click on your machine name. Select New | Web Site from the shortcut menu. This will start the New Web Site Wizard.
•Specify the name of your site and the IP address the site will map to.
•Set up a home or root directory for your Web site.

Configuring the Web Server

You need to configure at least one directory in your Web site with appropriate permissions to execute ASP files. This directory should preferably be the root directory of your Web site or a subdirectory of the root directory.
Follow these steps to configure an appropriately chosen directory in your Web site:

•    Open the MMC window.
•    Choose the directory you want to configure in your Web site.
•    Right-click on the name of the directory and select
•    Properties from the shortcut menu.
•   Enable the appropriate permissions for accessibility to (files in) the directory over the Web under the Directory or Virtual Directory tabs, as the case may be.

Creating a Virtual Directory

•    If you use a directory other than the root directory or its subdirectory to store your ASP files then you have to make this directory accessible to the Web server.
•    Create a virtual directory on the Web server and map it to the actual physical directory.
•    Open the MMC window.
•    Right-click on the name of your Web site and select New Virtual Directory from the shortcut menu. This will start the New Virtual Directory Wizard.
•    Give a suitable name for the virtual directory.
•    Select the physical directory that you want to link this virtual directory to.
•    Enable suitable privilege rights for the newly created directory.

Creating Active Server Pages

You can create Active Server Pages using any standard text  editor such as Notepad.
Save them with the extension, .asp in the directory that you have just configured.
Using Active Server Pages

•    Always request the Web server for an ASP file.
•    If the ASP file is located in a subdirectory of the root directory  or a virtual directory then you must write the full path of the file  relative to the root directory of your Web site.

Intoduction to VB Script

An Active Server Page is basically a scripting environment. A scripting language can be regarded as a simplified programming  language. But it is interpreted and it cannot be used to create stand alone applications. Scripts are embedded as text in Web pages and require a host to interpret them. The host can be a Web server or a Web client (browser).

  • VBScript was originally used to interpret user events triggered within the Internet Explorer.
    IIS 3.0 and higher versions include the scripting engine of VBScript,  by default.
  • Server-side processing of scripts enables the Web server to customize, create and deliver user-defined Web pages to the browser.
  • VBScript is a safe and secure scripting language.

Visual Basic Scripting in Active Server Pages

Scripts should always be enclosed within the script delimiters, .  Output can be displayed in the browser window using either the Response.Write method or the ASP output directive bound by the


  • All variables in Visual Basic scripts follow a standard naming convention. Variable names:
  • Cannot contain an embedded period.
  • Cannot contain more than 255 characters.
  • Must start with an alphabet.
  • VBScript allows not declaring variables explicitly.
  • Explicit Declaration of Variables
  • You can declare variables explicitly using the keyword DIM.
  • You can force the explicit declaration of variables using the OPTION keyword.


Setting the Scope of Variables

Public variables: Public variables are script-level variables whose scope extends throughout the page.

Public varname[([subscripts])]

Private variables: Private variables are also script-level variables whose scope is limited to the script in which they have been declared.
Private varname[([subscripts])] 

Empty Variables

Variables that have not been assigned any value at all are said to be empty.
You can test whether a variable is empty by using the function,


Datatype of VBScript Variables

  • All variables in VBScript have a variable datatype known as variant.
  • Variables have an underlying datatype, known as the subtype.
  • The subtype of a variable assumes the datatype of the value assigned to it.
  • You can find out the subtype of a variable using the function,


The value of a constant cannot be changed anywhere else in the script except at the place where it has been declared.


An array is also a type of variable. But it must be declared first.

DIM days_of_week(6)    REM A single dimensional array


An index number or subscript is used to refer to elements of the array.
DIM days_of_week(6, 2)   REM A multi dimensional array
days_of_week(0,1)=”Tennis at the club”
days_of_week(1,1)=”Seminar at IHC”

VBScript supports upto 60-dimensional arrays.

You can find out if a particular variable name refers to an array by using the function,


VBScript supports dynamic arrays. You must first specify the dimensions and size of the array before assigning values to the different array elements.
DIM shopping_list()    REM A dynamic array
REDIM shopping_list(1)
shopping_list(0)=”Tea Bags”

  • A REDIM statement is used to redimension the array.
  • The PRESERVE keyword is used to retain the data assigned to the array before the array is redimensioned.
    You can check the size of an array’s dimensions using the UBOUND() function.
  • Dynamic arrays can be destroyed after use with the help of the ERASE keyword.
  • Using Mathematical Operators and Functions
  • VBScript includes common mathematical operators and functions.
  • Mathematical Operators supported by VBScript


Mathematical Functions supported by VBScript


Random Numbers

The VBScript function, RND() generates random numbers greater than or equal to zero and less than one. To actually make the numbers random, you must use the randomize function, RANDOMIZE with the random function.

Using Logical Operators and Functions

VBScript supports common logical or comparison operators.








Like it on Facebook, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet