CHAPTER 3
Extending Active Server Pages


Chapter 1, Active Server Pages: An Introduction, presented a very brief overview of
the Active Server Pages application paradigm. This chapter covers the various
extensions for ASP. Some of these are included with IIS 4.0 and ASP 2.0, and some
are available via the World Wide Web.

Extending Active Server Pages applications usually takes the form of instantiating
server-side objects that expose methods and properties that you can access
through your server-side code. Microsoft includes many of these Active server
components with IIS 4.0. For example, one of the server components included
with IIS is the Browser Capabilities component. Once instantiated, a Browser
Capabilities object allows you to discern details about the user’s web browser:
what scripting it supports, what platform it is running on, and so on. This component
allows you to dynamically alter your site in response to the presence or
absence of certain browsers.

As will be discussed in Chapter 8, Server Object, you use the CreateObject method
of the Server object to instantiate a server component. For example, to create a
MyInfo object in your Active Server Page, you could use code similar to the
following:
<%
' Declare local variables.
Dim objMyInfo
' Instantiate a MyInfo object.
Set objMyInfo = Server.CreateObject("MSWC.MyInfo")
' You can now initialize the values.
objMyInfo.PersonalName = "A. Keyton Weissinger"
...[additional code]
%>

As you see in this example, instantiating these server components is simple. Once
instantiated, you can use any of an object’s exposed methods or properties to
extend your web application.

Although IIS comes with several server components, you also can write your own
in any development language that can create COM objects, such as Microsoft
Visual Basic, Visual C++, Visual J++, or Inprise’s Delphi. The details of writing
server components are beyond the scope of this book, so I would encourage you
to read O’Reilly’s forthcoming Developing ASP Components, by Shelley Powers.
The server components discussed in this book are described in Table 3-1.
Table 3-1: Server Components Discussed in ASP in a Nutshell
Server

Component Description
ADO Adds database access to Active Server Pages applications.
Through its COM interface to OLE DB data providers, you are
able to access any OLE DB or ODBC compliant data source.
Browser
Capabilities
Easily determines the functionality supported by your user’s
web browser.
Collaboration
Data
Objects for
NTS
Adds messaging functionality to web applications. Using the
objects that make up CDONTS, you can create robust, mailenabled
groupware applications using ASP. Although only
introduced in this book, CDONTS is a powerful extension to
ASP.
Content
Linking
Maintains a linked list of static content files. From within these
static files, the Content Linking component allows you to set up
easy-to-use navigation from one page to the next (or previous)
page.
Content
Rotator
Creates a schedule file containing several pieces of HTML that
are alternately placed in your web site. This component is
similar to the Ad Rotator component but works with straight
HTML content rather than advertisements.
Counters Maintains a collection of counters, over the scope of an entire
ASP application, that can be incremented or decremented from
anywhere in your web site.
File Access
Components
Allows you to access your local and network file system. It’s
part of the scripting runtime library that’s installed and registered
by default when you install IIS.
MyInfo Maintains commonly accessed information, such as the
webmaster’s name, address, company, etc., from within your
web applications.
Page Counter Creates a page counter on any page on your web site. The
page count is saved regularly to a text file. This allows you to
maintain page count information even if the web server is
restarted.
Permission
Checker
Checks the permissions on a given resource on the local
machine or on the network. This allows you to determine on
the fly whether the current user has permission to see a file.

PART II

Object Reference
This part covers every aspect of the intrinsic objects that make up the IIS
object model. This includes every event, method, property, and collection
for the Application, ObjectContext, Request, Response, Session, and Server
objects. This part also includes a reference for all of the ASP directives and
in-depth coverage of the GLOBAL.ASA file.

Because support for these objects, as well as for the GLOBAL.ASA file, is
built in to Active Server Pages, you can access and take advantage of all of
these components from ASP automatically; no additional components or
libraries are needed.
Part II is organized into the following chapters:
Chapter 4, Application Object
Chapter 5, ObjectContext Object
Chapter 6, Request Object
Chapter 7, Response Object
Chapter 8, Server Object
Chapter 9, Session Object
Chapter 10, Preprocessing Directives, Server-Side Includes, and
GLOBAL.ASA

Chapter 4