Wise ASP Logo Surfer's Choice Member
   

Wise ASP - HTML Form Elements and The Request Object

How Users Send Information

The traditional method for a web browser to communicate with the server was through forms, where information was sent to a server CGI program. A form consists of a group of fields to fill in. Forms are designed to enable users to send information back to the server. However, the ASP object model allows us to collect information passed with a query, and more, so that we can use it in our scripts.

  To be able to manage the way HTTP communications work ASP has to be able to capture all the information from each individual request made by the client, and store it so that it can be accessed by the application, running on the server. To do this, the request itself and a whole host of other information are placed in a Request object.

Introduction to Request.QueryString and the GET Method

Of the form itself, there is little to write. The tag itself can be qualified with an HTTP action. The action attribute tells the browser where you would like the form submitted; the default is the URL of document itself. Also, the tag can be qualified with an HTTP method. The form with a GET method has the following characteristics:
<form name=myForm action="response.asp" method=GET> ... </form> 
  Appending the query string to the end of a URL (the way the GET method works) usually isn't the best way to send information. For a start, the values of the controls are clearly visible in the browser's address box, and could very easily be intercepted while the request is in transit over the Internet.
var whatever = Request.QueryString("yourFormField"); 
  The query string method also suffers another severe limitation. The amount of data that can be sent with the URL is limited to around 1000 characters, as part of the HTTP protocol specifications. But there is another way to get data ...

Introduction to Request.Form and the POST Method

... There is a second way of sending data from the form to the server. We can use the POST method. This buries the information inside the HTTP header, rather than adding it to the URL as a query string:
<form name=myForm action="response.asp" method=POST> ... </form> 
  When this page is submitted, the names and values are encoded into the request header, and there is no sign of them in the browser's Address box. In this case, the values from the controls are placed in the Request objects Form collection:
var whatever = Request.Form("yourFormField"); 
  To iterate through the data requires that all the form elements be named. We can use the Enumerator object to iterate through Form collection, as described in my article.

The rest of this column will present the form elements in turn, and describe in detail how to use the Request object to process it.

  That's the end. Thanks for reading and feel free to jump around Wise ASP using the select box at the top of the screen.

88x31cardsvisoranm