ASP Request Object
The Request object provides access to all the information that is passed in a request from the browser to the server. This information is stored among five types of Request collections. Individual items in the collection are accessed via a unique key assigned to that item.
Specifies the total number of bytes sent in the body of the HTTP request.
Contains the values of the client certification fields of the request. Used in SSL protocols.
Contains the values of the cookies sent in the request.
Contains the values of the <FORM> elements posted to a form using the POST method.
Contains the values of the HTTP query string, which are the statements in the URL that follow a question (?) mark.
Contains the values of server environmental variables. This allows access to the HTTP headers.
Retrieves the data that was sent to the server from the browser as part of a POST request, and returns the number of bytes read.
Tips & Hints
Looping Through Collections
You can use VBScript's "For Each - Next" control statement to quickly loop through all of the items in a collection.
'looping through items of the Request.QueryString collection
For Each i In Request.QueryString
Response.Write i & " = " & Request.QueryString(i) & "<br>"
For example, if your URL
then the above code would result in:
type = e2node
node = HTML
This comes in handy when processing a form with dozens of inputs.
All variables can be accessed directly by calling Request(variable) without the collection name. In this case, the web server searches the collections in the following order:
This is a time saving shortcut while coding, but you have to be careful if you have more then one variable of the same name.
<form method="post" action="save_page.asp?save=yes">
<input type="text" name="save">
<input type="submit" name="submitForm" value="Submit">
This will write "yes", not
what the user typed in the form's text input field.
Optimizing Performance - Request(variable) vs. Request.Collection(variable)
A pitfall of using Request(variable) is that it takes the server longer to locate the item then if you use the fully qualified name, since the server has to sequentially search each collection for the item. While this is probably not going to make a difference on your personal web page, heavily loaded servers would notice a significant increase in efficiency by using the fully qualified name.
Back to ASP Objects
All code is my own (and may cause premature balding).
(v 3.0) indicates that this feature is only available with ASP Version 3.0, which shipped standard with IIS 5.0