the complete webmaster
tutorials reviews reference
ASP
CGI
FrontPage
HTML
Java
JavaScript

Sponsored by El Scripto

Visit the Mortgage Loan Place for Home Loans and also click here to find VA Loans on our site.

Open software to automate your online business

home / articles / asp

Active Server Pages: An Introduction to Web-based Application Development

Welcome. This article is the first of many in an ongoing series about developing  web content using Microsoft’s Active Server Pages. It is intended for developers and webmasters who are new to Microsoft’s active content strategy including Internet Information Server (IIS), Active Server Pages (ASP), Active Data Objects (ADO) and the Component Object Model (COM) but are not necessarily new to the Windows NT Platform, Microsoft products or web development  in general.

This series will be produced bi-weekly to provide how-to information on building web applications from the ground up in the Active Server Pages environment. We will cover topics such as scripting, database access, component object development and application integration using the suite of tools provided in Microsoft Visual Studio 97 and Internet Information Server.

If you’ve been building dynamic web sites using tools such as Perl, C, ISAPI or other technologies such as Microsoft’s Internet Database Connector or Allaire’s Cold Fusion, I urge you to read ahead to see what’s possible using the latest server-side technology from Microsoft - Active Server Pages.

An Introduction to the Active Platform

Microsoft has a very 'active' perspective on how application architectures should be created.  For that matter, the word 'active' or more specifically, the term ActiveX, has become a standard part of packaging  just about every product concept released from Microsoft within the last year.

Active Platform is the name given to Microsoft's component-based application development model for the Web. Active Platform is divided into three major sections:

  • Active Desktop - an ActiveX-enabled client architecture designed to house components and language-independent scripting environments
  • Active Server - primarily intended to provide an execution environment for running business logic distributed across enterprise application servers
  • ActiveX Technologies - the object-based underpinnings of all of the above - commonly referred to as The Component Object Model, or COM

Given that definition, let's turn our attention to where server-based applications are created.

The Active Server Side of Things

Active Server components actually constitute what we traditionally think of as the 'middle' tier, or business rule layer of an enterprise application.  These components are responsible for encapsulating the majority of an application's transaction and database logic.  For example, you might decide to place the logic for a complex calculation that requires access to several database tables inside an Active Server component.  This component would then be invoked by other Active Server components during execution of one or more of your enterprise applications. 

The server-side execution environment  that makes much of this possible is named Active Server Pages (formerly code-named "Denali"), an environment   in Microsoft Internet Information Server that executes ActiveX Scripts and ActiveX Components on a server.

Welcome to Active Server Pages

Active Server Pages are a key component of Microsoft’s dynamic web content strategy. With Active Server Pages, a software developer can create interactive and personalized web pages for their World Wide Web site or corporate intranet without having to understand the internals of a web server or complex application programming interfaces. In addition, Active Server Pages is extensible via software components written using Microsoft’s Component Object Model so you’ll be able to take advantage of code you’ve already written using languages such as Visual Basic, C++ or Java.

A Little History

The World Wide Web came to life in 1990 when researchers at Switzerland’s CERN laboratory needed to distribute documents and graphics via the Internet but needed something more than simple file transfers. It’s a familiar story, but it was this series of events that led up to the creation of the most significant evolutionary period in application development.

From Web Sites to Web Applications

After the initial introduction of the web, a specification emerged: CGI, or the Common Gateway Interface. This specification allowed resources, in the form of executable programs, to be requested by a web browser and  executed by a web server via a standard Uniform Resource Locator or URL.

These CGI-based programs could take user input in the form of command line parameters and use the standard input and output file handles of a program to receive and generate HTML output in response to a browser’s request. In addition, various pieces of state information located on the server could be interrogated by the program during execution and used to make logic decisions as to how this processing should occur. The ultimate goal: use this logic and processing capability to provide a custom experience for the user on the other side of the browser.

In one way or another, what emerged was a means of using logic far beyond the capabilities of HTML to accomplish standard data processing functionality such as input validation and database access and the power to distribute that processing across the world.

Where Active Server Pages Fit In

Active Server Pages were introduced with release 3 of Microsoft’s web server, Internet Information Server or IIS. Active Server Pages are actually a series of dynamic link libraries or DLLs that are installed on your web server by either a standalone installation program or as part of the Visual Studio 97 setup for Visual InterDev. These DLLs give IIS the ability to interpret and process information via the use of a script file (called an ASP script) that is resident in your web application directory.

Scripts and Why They Are Different

Once you complete the installation of Active Server Pages, a web browser can request scripts just as if it were requesting an HTML file. The difference is these files contain Active Server Page script, usually in the form of VBSCRIPT or JSCRIPT, and have a file extension of .ASP.  When requested, these scripts execute in the Active Server Page environment instead of being simply returned to the browser and produce output for sending back to the requesting browser.

You may be wondering just how quickly, if at all, you or your web developers could take advantage of this technology.

For starters, let’s take a look at how you get your Active Server Pages environment up and running. Then we’ll build our first script that dynamically generates an HTML page.

Installing the Active Server Pages Environment In Windows NT

Whether your platform is Windows NT Server 4.0, Windows NT Workstation 4.0 or Windows 95, you will need to first install and start a web server that is compatible with the Active Server Pages environment.

To date, each of these platforms provide a web server that supports Active Server pages. For Windows NT Server there is Microsoft’s Internet Information Server, for Windows NT Workstation there’s Microsoft’s Peer Web Services, and for Windows 95, there’s Personal Web Server.

If you’ve ever installed Windows NT Server 4.0, you have probably been asked if you want to install Internet Information Server. Answering ‘Yes’ to this question will install the default configuration for Internet Information Server version 2.0. Then, you’ll need to install NT Service Pack 3. This will upgrade your current IIS 2.0 installation  to 3.0, the necessary release for Active Server Pages.

After installing IIS 3.0, you’ll need to install Active Server Pages. You’ll find this installation either on the Microsoft Web download page, NT Service Pack 3, or as part of your Visual Studio 97 installation.

Now you’re ready to write your first script:

Active Server Pages 101

The following script can be written using a text editor such as the Windows NotePad.  Its' intent is to display four lines of text in the browser window that say "Hello ASP World!" each in a larger font:


HELLO.ASP
 

<%@ LANGUAGE="VBSCRIPT" %>

<HTML>
<HEAD>
<TITLE>My First ASP Script!</TITLE>
</HEAD>
<BODY>

<% for x = 3 to 6 %>
<FONT SIZE=<% =x %>>Hello ASP World!</FONT><BR>
<% next %>

</BODY>
</HTML>


Notice there is a mixture of what appears to be HTML and BASIC. The BASIC is actually VBSCRIPT and the HTML is, you guessed it, plain vanilla HTML.  Let’s take a quick tour of this example and see what it’s made up of and what it produces as its final output in the browser.

HELLO.ASP includes three standard HTML elements: HEAD, TITLE and BODY. For all intents and purposes, this is the proposed HTML page to be sent to the requesting browser when the HELLO.ASP page executes.

If you look closely, you’ll see several occurrences of "<%" and "%>". These angle-bracket percent signs are the opening and closing tags for a block of ASP script. You should note that ASP is not really a script, its actually a host environment for any number scripting languages such as VBSCRIPT, JSCRIPT and others including even a third-party Active Server Page version of   PerlScript.

A Dissection of HELLO.ASP

The first line of HELLO.ASP is actually a special scripting tag that tells the ASP interpreter to set the default scripting language to VBSCRIPT.  As discussed earlier, the target language could have very well been JSCRIPT. The only condition is that the language in question must be registered as a valid scripting language in the server’s registry.

<%@ LANGUAGE="VBSCRIPT" %>

The next five or so lines are  HTML. We set a title then we open the BODY section of the document.

<HTML>
<HEAD>
<TITLE>My First ASP Script!</TITLE>
</HEAD>
<BODY>

The next three lines make up the substance of our ASP script.

If you are familiar with the BASIC language, you’ll immediately recognize the ‘for-next’ looping construct in the code sample below. For those of you who are not, ‘for-next’ is a BASIC language construct that allows a block of code to execute for a number of times. In this example, ‘x’ is a variable that initially has a value of three and is incremented until, or to, the number 6 – in other words we execute the code between the for and the next four times.

<% for x = 3 to 6 %>
<FONT SIZE=<% =x %>>Hello ASP World!</FONT><BR>
<% next %>

The code within the body of the loop is as follows:

<FONT SIZE=<% =x %>>Hello ASP World!</FONT><BR>

The only thing left to explain is the <% =x %> occurring on the right of the SIZE= attribute of the FONT tag. This notation indicates that the contents of a variable named x will be substituted (which in this case will be 3, 4, 5 or 6) into the line prior to sending the HTML back to the browser.

What’s actually generated and sent back to the requesting browser, is pure HTML that looks like this:

<HTML>
<HEAD>
<TITLE>My First ASP Script!</TITLE>
</HEAD>
<BODY>
<FONT SIZE=3>Hello ASP World!</FONT><BR>
<FONT SIZE=4>Hello ASP World!</FONT><BR>
<FONT SIZE=5>Hello ASP World!</FONT><BR>
<FONT SIZE=6>Hello ASP World!</FONT><BR>
</BODY>
</HTML>

And what’s rendered in the browsers document window looks like this:

Hello ASP World!
Hello ASP World!
Hello ASP World!
Hello ASP World!

In Conclusion

What you’ve just seen is an introductory example of producing dynamic web content with Microsoft’s Active Server Pages.  No doubt, in the preceding code we could have done a few extra things to interact more with the environment.  For example, we could have solicited some of the information used to produce this page from the user such as the beginning and ending font sizes (i.e. the initial and maximum values for the for-next loop).   We'll see how this is possible a little later on.

However, from this article you should remember several key concepts:

  • Active Server Pages is an environment that hosts one of several scripting languages that can be used to produce output, in the form of HTML.   This interactivity is the key method used to 'activate' your web site.
  • To create an Active Server Page script, you simply write a combination of script and HTML and place it in a file with the extension .ASP.  There's actually more to it than that, but you're starting to get the picture...
  • Once installed, the Active Server Pages environment will process your script and interact with the server environment to produce HTML that will be sent to the requesting browser.  Without this environment installed, you will more than likely just receive the source of the ASP script displayed in your browser window.

Where We're Headed Next

Over the next several articles, we’ll be investigating some of the more advanced steps you’ll take to activate your web site. You'll learn about intrinsic objects available to you when writing Active Server Page scripts then you'll see how to create COM components and fully  integrate them into your web application.  Eventually, we'll integrate Active Data Objects and HTML forms to produce a full-featured data-entry application.  

For some additional reading, you might want to try "Professional Active Server Pages" published by Wrox Press.   I'll make other reading suggestions available to you as we proceed throughout our discussions. 

See you next time!

 

 

Author: Keith Cox
Date: 12/22/97

More articles about Active Server Pages
More articles by Keith Cox
Author Biography

Get thousands of people selling your product online for FREE
write for us about us advertise

Copyright 1997, 1998 A Big Lime. All rights reserved.

body>