These objects are part of the ASP.DLL and are always available to your ASP applications.
The Application object represents your ASP application itself. This object is universal to all users attached to an application, and there is only one Application object for all users. The Application object has two events, Application_OnStart and Application_OnEnd, that fire when the first user requests a page from your application and when the administrator explicitly unloads the application using the Microsoft Management Console (see Chapter 4), respectively. The OnStart event can be used to initialize information needed for every aspect of the application. The OnEnd event can be used to do any custom cleanup work after the end of your application. You can store any variable type (with some limitations—see Chapter 3) with application-level scope. These variables hold the same value for every user of the site. See Chapter 4 for more information on the Application object.
In this book, an ASP application is a group of scripts and HTML content files that together form some function.
Added in Active Server Pages 3.0, the ASPError object allows developers to access properties that characterize the last error that occurred in the currently executing script. It is only accessible through the Server object's GetLastError method and its properties are all read-only. The addition of the ASPError object is an important one in Active Server Pages 3.0 and significantly improves the handling of errors in Active Server Page scripts. See Chapter 5, and Chapter 9, for more information.
The ObjectContext object is actually part of the Microsoft Transaction Server and is only interfaced through ASP. The ObjectContext object allows you to create transactional Active Server Pages. The functions in these pages that support transactions will succeed as a single unit or fail completely. If your application requires the use of functions that do not natively support transactions (notably file access), you must write custom code to handle success or failure of these functions. See Chapter 6, for more information.
The Request object represents the way you interact with the client's HTTP request. This is one of the most important objects in the ASP object model. It is through the use of the Request object that you access both HTML form-based data and parameters sent over the address line. In addition, you can use the Request object to receive HTTP cookie information and client certificate information from your users. Finally, the ServerVariables collection of the Request object gives you access to all the information in the HTTP request header. This information contains (in addition to the cookie information) other relevant data describing the client machine, its connection, and its actual requests. The ServerVariables collection is equivalent to environment variables in traditional CGI applications. See Chapter 7, for more information.
The Response object represents your access/control over the HTTP response sent back to the user. Through the Response object, you can send cookies to the client and set if and when content should expire. In addition to this, the Response object is your route to completely controlling how data is sent to the client. Is it buffered before sending? Is it sent as it is constructed? Finally, the Response object allows you to seamlessly redirect the user from one URL to another. See Chapter 8, for more information.
The Server object gives you access to the web server itself. This object contains many utility features that you use in almost every application. Through the Server object, you can set the timeout variable for your scripts (how long the web server will attempt to serve a script before serving an error note instead). You also can use the Server object to map a virtual path to a physical path or encode information for sending over the address line. The most important method of the Server object, however, is its CreateObject method, which enables you to create instances of server-side components. You will use this method any time you require functionality outside that provided by the built-in objects. Database access, for example, is handled by various ActiveX Data Objects that must be instantiated on the server before being used. See Chapter 9, for more information.
Finally, the Session object holds information that is unique to a specific user's current session on the web server. Each user session is identifiable through the use of a unique cookie that is sent to the user every time the user makes a request. The web server starts a session for every new user that requests a page from your web application. This session stays active by default until 20 minutes after the user's last request or until the session is explicitly abandoned through code. See Chapter 10, for more information.