Using Other Collections

Now that you get the idea, the rest of the Request object is simple and straightforward.

ClientCertificate

This collection contains information about any certificates passed to you by the requesting browser.  A complete discussion of certificate based authentication is beyond the scope of this article, however, certificates provide a standard means to digitally identify the sender of a request which may be important to your application.   For more information on digital certificates and security, in general, please visit Verisign Corporation's website or visit the Microsoft Security website for a more detailed look at how this idea of authentication can be applied to you architectural needs.

ServerVariables

Another collection provided by the Request object is the ServerVariables collection.  This collection contains header information sent as part of the HTTP request header and often contains information regarding the value of server-based environment variables.

An example would be the request method used by the requesting browser.  A sample of what this looks like is as follows:

Request.ServerVariables("REQUEST_METHOD")

This code would produce GET, POST, or HEAD, depending on the method used by the browser to send data to the server.  Try the following server variables in your code to see the results:

Response.Write Request.ServerVariables("ALL_HTTP")
Response.Write Request.ServerVariables("REMOTE_ADDR")

Cookies

The cookies collection is slightly different than all other collections.   The Form and QueryString collections, for instance, represent information applicable only to the current request.  The Cookies collection, on the other hand, behaves slightly different.

First, a cookie is a small packet of information sent by the browser to the server via HTTP and hence available in the Request object.  The information stored in a cookie can be temporary or can be stored in a file on the user's disk if they choose to allow it.  Cookies, in general, were introduced into the HTTP 1.1 protocol specification to allow a means of lightweight persistence in the HTTP protocol.

In the context of the Request object, this collection is read-only and contains information held by the client browser.  We can modify this collection via the use of the Response object, which allows our application a more finely-grained approach to controlling how this information is managed.  We'll talk more about cookies in our next article when we dig into the many details of the Response object.

Your Mission If You Choose to Accept It

Your programming assignment for next week, if you choose to accept it, will be to explore the collections of the Request object.  That means you'll have to make use of some of the examples we discussed earlier, and some of the programming constructs such as FOR/EACH/NEXT.  Remember our trivia discussion regarding the order in which these collections are searched for the variable in question, if no explicit collection is specified in the syntax.

Write a sample ASP page, that when requested, loops through each collection and prints a very simple listing of collection variables and their values.  You may need to refer to the online documentation, and you may be able to use the code provided and copy/paste the collection you want to display.  It should look something like the following code:


<H3>A Collection Example</H3>
<%
For Each Item in Request.QueryString
Response.Write Item & " = " & Response.QueryString( Item ) & "<BR>"
Next
%>


Also, using some of the sample Form code, try to submit data from an HTML page to an ASP script using, as we have above, a well-known method of the Response Object to display the value on another page.

Page 1: A Brief History of Objects
Page 2: COM is the Basis for Microsoft's Object Strategy
Page 3: Using Objects and Object Models
Page 4: Active Server Pages Objects
Page 5: Requests and Responses: An HTTP Perspective
Page 6: Using the Request Object
Page 7: A Change of Method
Page 8: Using Other Collections
Page 9: Tip of the Week and Summary

Author: Keith Cox
Date: 12/29/97

More articles about Active Server Pages
More articles by Keith Cox
Author Biography

body>