The Request Object

Home  »  ASP  »  The Request Object


     The Request Object is useful for reading form field values. However, the Request Object is not limited to form processing.

Contents

What HTTP header are

When the clients requests a Web page from the server, it not only sends the URL of the Web page requested but also some additional information. This extra information consists of useful facts about the client. For example, this added information can include what browser is being used, what operating system the client is running, and what URL the user just came from. Each piece of additional information is referred to as a request header.

A request header is a single line of text that your browser sends to the Web server when requesting to view any Web page. A browser can send no headers, or several headers. Mainstream browsers all send a set of common headers.

When the server sends back the requested Web page to the client, it also sends a set of headers, known as response headers. Response headers are additional bits of information about the Web page being sent to the client. Both the request headers and the response headers are referred to , more generally, as HTTP headers.

An HTTP header is a single piece of information, sent either from the client to the server, when requesting a page, or from the server to the client, when responding to a page request.




Reading the HTTP Headers with Request.ServerVariables



Output of "HTTPHeaders.asp"






Reading the Environment Variables Using Request.ServerVariables



Output of "Env_Variables.asp"

Contains all the HTTP Headers & Environment Variables



Output of "HTTPHeaders-Env_Variables.asp"

HTTP Headers & Envrionment Variables - Demo




What Cookies are

Cookies are small bits of information, such as strings and numeric values, stored on the client's computer for a specified amount of time. When cookies are created on the client's computer, the developer needs to specify when they expire. After a cookie expires, it will automatically remove itself from the client's computer.

How to read cookies using the Request Object

Cookies are stored and read using the HTTP headers. Each time the browser requests a Web page, it sends the cookies that the current Web site created. You can use the Cookies HTTP header to read the cookies. For example, if you create an ASP page on your Web server that contains the following code:

How to write cookies using the Response Object

Now that you know how to read cookies from the client's computer, it's about time that you learn how to write them. the HTTP headers that the Web server sends to the browser before it sends the actual Web page requested by the client. Cookies are written to the client's computer through the use of response headers. Therefore, it's not surprising to find that cookies are written to the browser using the Response object.

The Response object, like the Request object, has Cookies collection. The following code writes a cookie to the client's computer:




Using the Cookies



Output of "UsingCookies.asp"




UsingCookies - Demo





Using the Keys (SubCookies)







Share on Google Plus
    Blogger Comment
    Facebook Comment