Americas

  • United States

Wrapping up ASP

Opinion
Jan 20, 20034 mins
Enterprise Applications

* Gearhead columnist Mark Gibbs with his final week of the Active Server Pages tour

Well friends, this is it, the final week of our tour of Active Server Pages. Fair brings a tear to your one good eye, don’t it?

In a previous column we discussed the ASP object model and its Request Object and the Request Object’s Form Collection. I’m sure you won’t be surprised to learn that there are a lot more objects in the model. But first, we need to explain that ASP objects have properties (attributes such as Timeout values); collections (the elements or components of the object); methods (routines that manipulate elements); and events (such as OnStart, which is invoked when the application is loaded).

We also need to mention a rather complex ASP component – the GLOBAL.ASA file. This is where you declare objects, variables and event handlers that apply to sessions or applications. There can be one and only one GLOBAL.ASA file for each virtual directory or ASP application, and it can’t contain any displayable content; it can only contain scripts. In GLOBAL.ASA, you can add, examine, modify and delete elements in the StaticObjects Collection of the Application Object and create other custom objects as needed.

Here’s a whirlwind tour of ASP objects:

The Application Object: This object provides access to all the files in a specific virtual directory and is the same object to all users of a given ASP application. From an ASP application you can create variables in the application object that are shared or accessible to all users of that application – they are global variables. Using the Contents Collection of the Application Object you can add, examine, modify and delete elements (variables).

The ObjectContext Object: This object is part of the Microsoft Transaction Server and lets you create transactions using ASP (operation or groups of operations that must all succeed or fail completely).

The Request Object: This object, which we discussed a few columns ago, gives access to the HTTP request from the client through the ServerVariables Collection (server environment variables), while the Cookies Collection is for (you guessed it!), cookie data.

The ClientCertificate Collection is for client-side digital certificates and client machine description, and the Form and QueryString collections are used to retrieve the client data from POST and GET requests, respectively. It has no associated events.

The Response Object: We also discussed the Response Object in a previous column. This controls the HTTP response that is returned to the client, including cookies. There are a lot of properties and methods for this object but no events and a single collection for cookies.

The Server Object: This object is a window into the Web server. The Server Object has no collections or events but it does have methods to create objects, set timeouts for script execution, map virtual paths to physical paths, encode data and create server-side components to extend server functionality.

The Session Object: A Session Object is created for and is unique to each user session. Its role is to hold information about that session. It provides persistence of user state between requests – something that isn’t inherent in HTTP.

The properties of the Session Object include the code page value for the user’s locale, locale information (currency formatting and date order), a session ID unique to each user (stored on the client dynamically as a cookie), the session timeout value after which the session expires, and the unique session information is disposed.

The Session Object collections include the Contents Collection (all elements added by scripts, not through the GLOBAL.ASA file) and the StaticObjects Collection, which we discussed above. This object has only one method, Abandon, which disposes of the current session information for the user session that invokes the method (no other sessions are affected).

The Microsoft Internet Information Server system also includes installable objects such as the ActiveX Data Object, which provides database access, an ad rotator (just what every site needs), a file access component and a file access component.

Well folks, that’s it unless you want to get really down and dirty. Active Server Pages technology is a powerful tool for building Web applications and has even become available on non-Microsoft platforms such as Sun One Active Server Pages for Unix and Linux (see www.nwfusion.com, Doc-Finder: 3931).

Next week: Something completely different. Joyful cries to gearhead@gibbs.com.

mark_gibbs

Mark Gibbs is an author, journalist, and man of mystery. His writing for Network World is widely considered to be vastly underpaid. For more than 30 years, Gibbs has consulted, lectured, and authored numerous articles and books about networking, information technology, and the social and political issues surrounding them. His complete bio can be found at http://gibbs.com/mgbio

More from this author