Developing Web Applications

Previous Topic Next Topic

Built-in Objects and Server-Side Components

If you have ever written client-side script, you have probably found yourself using built-in browser objects such as document, form, and window. These objects are provided as part of the browser’s object model, and make interaction with the browser much more manageable. Likewise, ASP defines its own object model.

The Response object mentioned earlier is one of ASP’s built-in objects, of which there are currently six: Server, Application, Session, Request, Response, and ObjectContext. These objects greatly simplify the interaction between the server and the client. A description of each appears in the sidebar below, “The Built-in ASP Objects.”

In addition to built-in ASP objects, you can create and manipulate a variety of custom server-side components. By combining active scripting with server-side COM components, also known as server-side objects, you extend the functionality of ASP with powerful, easy-to-use packages. You can instantiate server-side components by using the CreateObject method of the Server object and passing it the ProgID of the component you wish to create. Once the component is instantiated, you can access any of its properties or methods. For example, the following script instantiates a server-side object with Server.CreateObject and stores a reference to it in the variable objAdRotator:

<% Set objAdRotator = Server.CreateObject("MSWC.AdRotator") %>
The Built-in ASP Objects

ASP provides built-in objects that make it easier for you to gather information sent with a browser request, to respond to the browser, and to store information about a particular user.

Server Object

You use the Server object to access methods and properties on the server. The most frequently used method is the one that creates an instance of a COM component (Server.CreateObject). Other methods apply URL or HTML encoding to strings, map virtual paths to physical paths, and set the time-out period for a script.

Application Object

You use the Application object to store global application settings and to share information among all users of a given ASP application.

Session Object

You use the Session object to store information needed for a particular user session. Variables stored in the Session object are not discarded when the user jumps between pages in the application; instead, these variables persist for the entire time the user is accessing pages in an application. You can also use Session methods to explicitly end a session and to set the time-out period for an idle session.

Request Object

You use the Request object to gain access to any information that is passed with an HTTP request. This includes name/value pairs passed from an HTML form using either the POST method or the GET method, cookies, and client certificates. The Request object also gives you access to binary data sent to the server, such as file uploads.

Response Object

You use the Response object to control the information you send back to a user. This includes sending information to the browser, redirecting the browser to another URL, or setting cookie values.

ObjectContext Object

You use the ObjectContext object to either commit or abort a transaction initiated by a script in an ASP page. For more information, see Data Access and Transactions in this book. You can also use this object to access the other built-in ASP objects from within a component.


To get you started, the default ASP installation includes several task-oriented components, including the MyInfo, Ad Rotator, and Browser Capabilities components. When you install the Microsoft® Data Access Components (MDAC), included with IIS 5.0, you can also use ADO to access information stored in a SQL Server, Oracle, Microsoft® Access, or other database.


© 1997-1999 Microsoft Corporation. All rights reserved.