Getting User Inputs from the Browser- The Request Object/Class


Introduction.  The Request object/class is used to obtain user inputted values from a form into some sort of ASP processing script. 

While we will focus almost exclusively on the Form collection of the Request class.  We present some other collections so that you will be aware they exist, though we will not do anything with them in this course..




Form When the form is created with METHOD=POST, use this to get the inputs from a submitted form.
QueryString When the form is created with METHOD=GET, use this to get the inputs to the form.  This causes the form input values to be picked up from an HTTP string.
ServerVariables Every time you visit a web page your browser sends a lot of information to the web server and vice-a-versa.  This information can be accessed with this collection.
Cookies Through the use of this collection you can store small bits of information on the client's computer.  These pieces of information can be used to determine return visitors or customize the content of your web for each visitor.
ClientCertificate Used to retrieve certification fields from a browser request.


Request.Form.  When you want to collect the information from a web form field with a particular fieldNAME use



This can be used to collect the inputs from text boxes, list boxes, check boxes and radio buttons.  The one thing that I seem to too often do is forget to put quotation marks around the filedNAME.  The first thing we want to do is modify the YouDidIt.asp we developed in the last web page to collect the values you type in and feed them back so you can see them.  This will result in a use of both Request.Form and Response.Write, two of major operational tools for developing ASP web based user interactions.

So you want to copy the following code into your YouDidIt.asp and upload it back to your root web.  CaveatEmptor.asp will stay the same.


<%@ Language=VBScript %>
<%Option Explicit%>
<P>You did it!!!
Dim strDomainName, strCountry, chkSpam, chkMailList, chkCallMe, radCardType

' Now we are going to list out all of the values you entered

' This is for the domain name you entered

strDomainName = Request.Form("DomainName")
Response.Write "<P>You requested " & strDomainName & " as your domain name."

' This is for the country you reside in

strCountry = Request.Form("Country")
Response.Write "<P>You claim you live in " & strCountry

' This is lists out ways for us to contact you

chkSpam = Request.Form("Spam")
chkMailList = Request.Form("MailList")
chkCallMe = Request.Form("CallMe")

Response.Write "<P>You have said you want us to<BR>"

If chkSpam = "on" Then

Response.Write "Spam you<BR>"

End If
If chkMailList = "on" Then

Response.Write "Mail you<BR>"

End If
If chkCallMe = "on" Then

Response.Write "Call you<BR>"

End If

' This is for your type of payment

radCardType = Request.Form("CardType")
Response.Write "<P>You are going to use " & radCardType & " to pay your bill."

<P> We thank you for your business!

The meaning of the code will be discussed in class.

Now you would get the following two screens on the web if you filled in the same entries.



After sending this on you should see the following.



Now you are ready to complete the Login.asp, which is really quite a bit simpler than what we have just done.  This will be done in the next web page.