BILKENT UNIVERSITY  
CS533 Information Retrieval Systems  
Technical Presentation Web Site
Barýþ UZ
 
Index of
this page
Introduction
Push Technologies
Channels
CGI
ASP
Java
Streaming Media
 
What is ASP?
Writing ASP Scripts
Using Scripting Languages
Getting Information from a User
Sending Information to a User
Develoing ASP-Based Applications
ASP Main Page with Tutorial and 
Selected Links
 
Sometimes we need to get information about the user, for example, the type of browser s/he is using, environment variables. We also need to get some data about the user himself/herself; like birthday, name, surname, etc. We use Request object to perform these actions. It allows accessing any information that is passed with an HTTP request, including the following: 
 
    A standard set of information included in the server variable set. 
    A set of parameters passed with the POST method. 
    A set of query parameters attached to the GET method. 
    Cookies that are passed from a browser. Cookies allow a set of information to be associated with a user 
    Client Certificates.
Ther Request object has five associated collections: 
    QueryString 
    Form 
    Cookies 
    ServerVariabes 
    ClientCertificate
The general syntax to access user information in Request object is: 
 
    Request.CollectionName(variable)
where CollectionName can be QueryString, Form, Cookies, ServerVariables, ClientCertificate and variable is the name of the variable in the collection to be accessed. 
 
    Request(variablename)
searches the collection in this order: QueryString, Form, Cookies, ServerVariables, ClientCertificate. 

Getting Information from HTML Forms 

In order to process HTML Forms, we can use ASP in one of the following ways: 

    A static .htm file can contain a form that posts its values to an .asp file. 
    An .asp file can create a from that posts information to ANOTHER .asp file. 
    An .asp file can create a form that posts information to ITSELF, that is, to the .asp file that contains the form.
Using the QueryString Collection 

QUERY_STRING variable can be used to evaluate the data coming from a form; however, ASP provides the QueryString Collection to make this information readily accessible. If the form method is POST, QueryString collection contains all the information passed as a parameter after the question mark in the URL. If the method is GET, the QueryString collection contains all the information passed in the form. 

Let's look at the following example: 
<A HREF="myasp.asp?name=Baris+Uz&age=24"> 

The following script uses the Request object to access these values: 

Welcome, <%= Request.QueryString("name") %>. 
Your age is <%= Request.QueryString("age") %>. 

The result is; 

Welcome Baris Uz. Your age is 24. 

If multiple entries exist for a variable, the object handles it in the following fashion: 

Assume that query string be: name=Baris&name=Emre&name=Ali 

then, 

Value of Request.QueryString("name")(1) is Baris 
Value of Request.QueryString("name")(2) is Emre 
Value of Request.QueryString("name")(3) is Ali 

This also supports the Count property which returns the number of entries for the collection. 
Response.QueryString("name") yields the result of "Baris, Emre, Ali". 

A similar property holds for Form collection. 

Posting Information to the Originating .asp File 

This can be used to control entries of the user for a form. For example, invalid telephone number, email address; incomplete filed determination, etc. Simply, we should give the .asp file name in the ACTION part of the Form. 

Using the Cookies Collection with the Request Object  

A cookie is a token that either a client browser sends to a web server or that a web server sends to a client browser. Cookies allow a set of information to be associated with a user. ASP can handle the values in the Cookies collection. The syntax is Request.Cookies("name")("key").

 
PREVIOUS TOPIC
UP
(First page of this topic)
NEXT TOPIC
PREVIOUS PAGE 
(of this topic)
NEXT PAGE 
(of this topic)