|
|
|
|
Request and Response Object
The request object is one of the most important intrinsic server object that the developer needs to understand. It provides a connection between the client and the Web server. It gathers data from there user's system and transfers them over to their Web server. Information can flow as a String. Form data, Cookies, or Server Variables. These are collection of the request object, each having its own variables. The request object is accessed in the following manner: Request. collection ("variable") If the collection is specified in the
statement, the request object looks up only that collection for the
variable. If it is not specified, all collection are searched for the
variable and the first match found is returned. The object looks up the
collections in the following order:
Query strings are the oldest form of passing data from the client to the server. They are generated by the HTTP get method, which is the default request method. Query strings appear in the URL itself. the location of the page is followed by a question mark then query string, as a list of variables and their values, separated by an ampersand (&). Query strings are passed to the URL in two ways. They can be passed from form variables using the Get method or by manually or programmatically appending the variables to the URL . This is the general form of query string:
Form variables are passed to the web servers using the post method. This feature was added only with HTTP 1.0 .IT was originally designed to pass large amounts of data between the client and server, since the Get method is limited to a fixed number of characters. as with the get method the elements are referred to as variables. the elements with the post method are referred to as parameters. The way to handle the form collection is identical to that of the QueryString collection. This is the general syntax. Request.Form("variable1")
The response object complements the Request object-- it handles interaction of the server with the client. The properties of the response object include buffer, Content Type , Expires Absolute and status. The most commonly used method of this object is the write method. This method writes data onto a page Hence, it is used to dynamically create a page. The other methods of this object are listed in the following table
The most fundamental process of ASP
development is writing HTML output. We have already used this method
earlier to write data to a page. The syntax is very simple .Any string
passed to the method is written to the page, Reponse.Write(<string-expression>) The string-expression can be a literal string, a variable or a function that returns a string. The parentheses are not necessary, but it improves readability of the code.
The response.Write method typically faces problems in two areas. When you wish to output %> to the HTML stream, the method may interpret this as a VBScript delimiter. There are two ways to overcome this. Both of the following would work: Response.Write("%" &
">") The second problem is encountered when trying to output double quotes to the HTML stream. VBScript would interpret this as the end of the string. Use the function Chr(34) for this. Response.Write("He Said, " & Chr (34) & "ASP is great." & Chr(34)) The rest of the methods of the Response object are pretty advanced. |
||||||||||||||||