You are on page 1of 3

Generated by Foxit PDF Creator © Foxit Software

http://www.foxitsoftware.com For evaluation only.

REQUEST OBJECT
The following HTML file creates a form (FORM2.HTML) that is used to collect various data.
The form shows how to use different input data types such as text box, option button, check box,
text area, and list.

<html>
<body>
<!-- Data collected in this form is processed by the ASP script called collectinfo.asp -->
<FORM METHOD = POST ACTION = "collectinfo.asp">
Last Name: <INPUT TYPE = TEXT NAME = LName> <BR>
First Name: <INPUT TYPE = TEXT NAME = FName> <BR>
Middle Name: <INPUT TYPE = TEXT NAME = MName> <BR>
<P>

<!-- Radio button used here - this segment shows how to create option buttons -->
Gender: <BR>
<INPUT TYPE = RADIO NAME = Gender VALUE = Male> Male
<BR>
<INPUT TYPE = RADIO NAME = Gender VALUE = Female> Female
<P>

<!-- Check box used here - this segment shows how to create check boxes-->
Languages Known: <BR>
<INPUT TYPE = CHECKBOX NAME = Languages VALUE = English> English
<INPUT TYPE = CHECKBOX NAME = Languages VALUE = Hindi> Hindi
<INPUT TYPE = CHECKBOX NAME = Languages VALUE = Marathi> Marathi
<INPUT TYPE = CHECKBOX NAME = Languages VALUE = Gujarati> Gujarati
<P>

<!-- List used here - this segment shows how to create lists-->
City: <BR>
<SELECT NAME = "CITY">
<OPTION Value = "Mumbai">Mumbai
<OPTION Value = "Delhi">Delhi
<OPTION Value = "Bangalore">Bangalore
<OPTION Value = "Chennai">Chennai
</SELECT>
<P>

<!-- Text Box used here - this segment shows how to create text area -->
Your Comments: <BR>
<TEXTAREA NAME = "message" ROWS = "5" COLS = "60"></TEXTAREA>
<P>
<!—Now create the submit and clear buttons -->
<INPUT TYPE = SUBMIT VALUE = "Submit Form">
<INPUT TYPE="reset" VALUE="Clear Form">
</FORM>
</body> </html>
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.

Prof. Mukesh N Tekwani


When the SUBMIT button is clicked, the following ASP script collects the information.

<% Option Explicit %>


<%
'This script is used by the HTML file FORM2.HTML.

Dim strLName, strFName, strMName, strCity, strgender


Dim strLanguages, strmsg
Dim arrLangs ' array to store languages

'Get the size of the request in bytes


Response.Write "The request size is : "
Response.Write Request.TotalBytes & " bytes " & "<BR>"

'Read the form field values using the Request object


strLName = Request.Form("LName")
strFName = Request.Form("FName")
strMName = Request.Form("MName")
strgender = Request.Form("Gender")
strcity = Request.Form("City")
strLanguages = Request.Form("Languages")
strmsg = Request.Form("message")

'Print the values collected


Response.Write "LName = " & strLName & "<BR>"
Response.Write "FName = " & strFName & "<BR>"
Response.Write "MName = " & strMName & "<BR>"
Response.Write "Gender = " & strgender & "<BR>"
Response.Write "City = " & strcity & "<BR>"
Response.Write "Languages = " & strLanguages & "<BR>"
Response.Write "Message = " & strmsg & "<BR>"
Response.Write "<P>"

'Now we split the string containing all languages and store each languagae in an array
arrLangs = split(strLanguages, ",")
Dim i

For i = LBound(arrLangs) to UBound(arrLangs)


Select Case Trim(arrLangs(i))
Case "English":
Response.Write "English <BR>"
Case "Hindi":
Response.Write "Hindi <BR>"
Case "Marathi":
Response.Write "Marathi <BR>"
Case "Gujarati":
Response.Write "Gujarati <BR>"
End Select
Next %>

Page 2 of 3
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.

Prof. Mukesh N Tekwani mukeshtekwani@hotmail.com

In the above code we see a property of the Request object called “TotalBytes”. This contains the
total number of bytes the client sent in the body of the HTTP request.

The request size is :


<% Response.Write Request.TotalBytes %>

SERVER Variables Collection:


This collection holds all the HTTP headers and additional information about the server and the
request. It gives information about the user’s browser type, version, OS, time locale, language, IP
address server’s domain name, server’s software, etc.

HTTP headers are sent along with a request for a Web page. Every time an ASP page is executed
by the server, the Web server creates a set of server variables that are sent along with the page.

The following ASP script shows how these server variables can be accessed:

<html>
<body>
<%
For Each key in Request.ServerVariables
Response.Write Key & " " & Request.ServerVariables(key)
Response.Write "<BR>"
Response.Write "<BR>"

Next

%>
</body>
</html>

Page 3 of 3

You might also like