Introduction to Active Server Pages





Until recent years, a typical computer application was a set of instructions written for a stand-alone machine, usually a personal computer. With the spread of the Internet, the world wide web brought another type of application whose popularity has only been asymptotically growing.

A web-based application is one that allows a person to interact with a computer using a browser. In the beginning of the Internet, this type of application mostly allowed a user to "view" web pages. Interaction was at a minimum. As the requirements grew, it was necessary to adventure in new ways of exploring the world wide web aspect of the Internet. This caused the birth or development of a new family of applications: web-based.

An application is referred to as web-based when it is used from a browser. Traditional computer applications were installed on a (stand-alone) personal computer from a floppy disk, a CD, or a DVD, etc. Users usually accessed the Internet only using a connection to an external server. Without the connection, the interaction was not possible. The next version of browser-based applications allowed a program also to require a browser but the application could be installed on a person's computer so that no connection was necessary to a server. This was the case for HTML help files: they still required a browser but its role was only to interpret HTML and other scripts that were part of the application.

Various scripting languages were developed to support web-based applications and enhance users experiences with the computer. Among these languages was Microsoft Visual Basic Scripting Edition, also called VBScript, which is still highly used today, along with JavaScript. After a while, Microsoft developed a technology referred to as Active Server Pages (ASP) which intended to support dynamic pages: web pages that can react to a user based on the contents of the page and the user's choices. It is important to know that many other technologies were developed by different companies also intending to offer more than the traditional viewing experience of web pages on the Internet.


Active Server Pages Prerequisites

To create an Active Server Pages application, you must prepare your computer, the one you will be using to develop your applications. Everything you need is amazingly free (compared to other libraries or platforms on the market). To start, you must have the correct operating system:

  • Microsoft Windows 98
  • Microsoft Windows NT (Workstation or Server)
  • Microsoft Windows XP Professional (no Home Edition)
  • Microsoft Windows 2000 Server
  • Microsoft Windows Server 2003 (any version)

Also, you should install the latest Internet Explorer browser. The minimum you should have is Internet Explorer 4.0 but, unless you have any particular reason, you should install the 6.0 version.

To support databases (even if you don't intend to create web-based databases), you should install the latest MDAC library, which is a free download from the Microsoft web site. Normally, you may have MDAC installed already but just in case you need it...

Along with one of the above operating systems, you must install Microsoft Internet Information Server (4.0) or Internet Information Services (IIS) 6.0. During the installation of some operating systems, you would have been prompted to install it.

If you are using Microsoft Windows 98, you must install Personal Web Server which is available in the CD or DVD you used to install the operating system.

If you are using one of the other versions of the OS, you can install IIS from Control Panel -> Add/Remove Programs -> Add/Remove Windows Components -> Internet Information Services (IIS) and follow the steps:

To follow the lessons on this site, you must be a little familiar with HTML and VBScript. It is not realistic to teach HTML and web application development at the same time.

For the rest of these lessons, we assume that you have a working installation of either PWS or IIS in your computer.

Development of an Active Server Pages Application


Creating a Virtual Directory

ASP is as free as possible. Once you have installed all the requirements, you have everything you need.

To start an application, because it is web-based, you must create a virtual directory for a web site. First, you must create a folder in one of your fixed drives, such as the C: drive. After creating the folder, you can open Internet Services Manager. This depends on the operating system you are using. In the MMC, you must create a web site using an alias associated with the folder you created 


Practical Learning: Creating a Virtual Directory

  1. Open Windows Explorer or My Computer
  2. In the left frame, click the drive you want to use
  3. Right-click the right frame -> New -> Folder
  4. Set the name of the folder to La Familia and press Enter
  5. To display the MMC,
    If you are using MS Windows XP Professional, click Start -> Control Panel. Double-click Administrative Tools and double-click Internet Information Services
    If you are using MS Windows 2000, click Start -> Programs -> Administrative Tools -> Internet Services Manager
  6. In the left frame (of the MMC), expand the name of your server (if you are planning to use another server or computer but is not listed, right-click Internet Information Services, click Connect, type the name of the computer and click OK) and optionally expand the Default Web Site node
    If you are using MS Windows XP Professional, you must expand Web Site under the computer
  7. Right-click Default Web Site -> New -> Virtual Directory
  8. In the first page of the wizard, click Next
  9. In the second page, type the name you will use on the browser to access the application you are creating. For our example, type family
  10. Click Next
  11. In the third page, type the full path to the folder you created above. For this example, click Browse. In the Browse For Folder dialog box, locate the folder you created
  12. Click Next
  13. The fourth page allows you to specify how the pages on this site will be accessed. For now, accept the defaults and click Next
  14. Click Finish and notice a new web site named family in the MMC

Creating a Web Page

A web page is primarily a regular text file. To develop it, you can use the good old Notepad, which should be installed in your computer already.

An ASP web page is a text document with the .asp extension (that's all we need to know for now).


Practical Learning: Creating a Web Page

  1. Start Notepad and type the following simple HTML code in the empty file:
    <title>La Familia: A Presentation</title>
    <h3>La Familia</h3>
    <p>This site is dedicated to <b>La Familia</b>,
     our charity organization intended to help those who affirm our cause</p>
  2. Save the file as presentation.asp in the La Familia folder you created earlier
  3. Open your browser and, if you followed the above instructions faithfully, change the address to http://localhost/family/presentation.asp and press Enter

Introduction to Code

A web page is primarily a text file with various HTML tags that the browser would interpret. To make it more interactive, you can upgrade it from a regular web page to an object of an ASP application. We saw above that the first step is to make it a file with .asp extension. In reality, what makes this page an enhancement is the code it has, which would be better than simple HTML tags. To accomplish this purpose, you must write code.

To enhance a web page and make it part of an ASP application, you typically "add" scripting code to it. This new code and the HTML tags must co-exist on the same page but there should not be any confusion. In fact, the HTML sections would have the normal tags that you are familiar with. To distinguish HTML from script, each section that has a script must start with the <% delimiter and end with the %> delimiter. Here is an example of such a section:

<title>Active Server Pages Tutorials</title>

<% %>


Anything between the <% and %> delimiters would be part of a script. This section is not directly intended for HTML code. In fact, if you include simple text or regular HTML code in it, you would receive an error. Consider the following code:

<title>Active Server Pages Tutorials</title>

<% <h1>Lesson 1: Introduction to Active Server Pages</h1> %>


If you want to include normal text paragraph(s) or HTML code in your page, simply type it as you do normally before or after a script section. Here is an example:

<title>Active Server Pages Tutorials</title>
<h1>Lesson 1: Introduction</h1>

<%  %>

<p>This lesson will present the Active Server Pages techniques of web development</p>

This would produce:

The <% and %> delimiters don't have to be on the same line. For example, in future lessons, you will see that you may need various lines of code. Based, on this, the <% delimiter may be one line and the %> delimiter may be a few lines under. The main rule is to always remember where you start the code with the <% delimiter so you can appropriately close it with the %> delimiter.


Home Copyright © 2005-2012, FunctionX, Inc. Next