ASP and VB Script - ASP Objects

We have seen previously an introduction to VB Script and ASP. In this tutorial we will study in more details ASP objects. This reference to many other articles may help you to understand topics not covered here.

We will discuss a few of the ASP objects: application, request, response, server. You can see a summary of the objects in ASP in the Microsoft ASP objects page.

  1. Application: Global.ASA

  2. Request: allows access to both header and body of the HTTP request.

  3. Response: allows control over the HTTP response to the client.

    1. Properties need to be inserted after <%@ LANGUAGE="VBSCRIPT"%> directive, but before the first HTML tag.

      • Buffer: controls if the response is sent as the page and script are created, or if are kept in a buffer and sent when processing is completed.
        Syntax: Response.Buffer = True       (False is the default)
      • CacheControl: allows caching by a Proxy server, but the Proxy server needs to be setup to cache pages.
        Syntax: Response.CacheControl = "setting" , where setting is Public or Private(default)
      • ContentType: allows setting the page content type. The default id text/html. Syntax: Response.ContentType = "type" . The following examples set the ContentType property to other common values:
        <% Response.ContentType = "text/HTML" %>
        <% Response.ContentType = "image/GIF" %>
        <% Response.ContentType = "image/JPEG" %>
        <% Response.ContentType = "text/plain" %>
        <% Response.ContentType = "image/JPEG" %>
      • Character set: allows setting the character set to be used. The default on the Web is ISO-LATIN-1.
        Syntax: Response.Charset ("charset")
      • Expires: specifies the lenght of time (in minutes) that a client will cache the ASP page. The default is 24 hours. Note: if you want to specify Options Explicit include Response.Expires = 0, otherwise you will receive an error message.
        Syntax: Response.Expires = intMinutes
      • others: ExpiresAbsolute, IsClientConnected,PICS, Status.

    2. Methods affect the behavior of the response. Lets see some of them:
      • Clear: empties the content of the buffer, not sending information to the client browser.
        Syntax: Response.Clear
      • End: sends all data currently in the buffer to the client and all other code after End is not processed.
        Syntax: Response.End
      • Flush: sends all data currently in the buffer to the client, but allows code after it to be processed and later sent to the client.
        Syntax: Response.Flush
      • Redirect: redirects the client's request to another URL. It can be a local or remote page URL.
        Syntax: Response.Redirect "strURL"
      • Write: writes information to the HTTP response body. To write special characters use the VB Script function Chr ( ). To add variables just use their names without quotes and & to include it in the message.
        Syntax: Response.Write("text")

  4. Server: provides additional methods and properties associated with IIS or PWS. We will see its only property and three methods:

  5. Session: allows the management of an user connection with the server. We will not discuss it here, like we did not discuss cookies. See the Microsoft ASP objects page on session.

This page is maintained by Al Bento who can be reached at This page was last updated on November 27, 2004. Although we will attempt to keep this information accurate, we can not guarantee the accuracy of the information provided.