g
Printer Friendly Version

editor  
BellaOnline's ASP Editor
 

Using the REQUEST Object


Response object is used to request information either from the user (by means of form) or from the server.

There are many methods assigned to it.

Some of them that are used mostly are :

1. Request.form("parameter")
This is used to get information passed from a FORM with the method of "POST".

Example:

<form name="form_name" method="post" action="this_page.asp">
† †<input type="text" name="customer_name" value="">
† †<input type="password" name="customer_password" value="">
† †<input type="submit" name="button" value="Submit">
</form>

when you click the "Submit" button, those information will be sent to "this_page.asp". All you have to do is to catch that variable on that page as follow :

<%
response.write "Customer Name : " & request.form("customer_name")
%>

Note that you can store that data into a variable first.

<%
Dim password

Password = request.form("customer_password")
response.write "Customer Password : " & password
%>

Also please note that a "password" fieldís data will be sent as if it is text data. The "***" or "ooo" while typing is for visual security only.


2. Request.querystring("parameter")
Basically, you would find this quite the same as request.form("parameter"). The difference is that this can be obtained not only from FORM with the method of "GET" but also from direct url typing.

Example1: FORM

<form name="form_name" method="get" action="this_page.asp">
<input type="text" name="customer_name" value="">
<input type="password" name="customer_password" value="">
<input type="submit" name="button" value="Submit">
</form>

when you click the "Submit" button, those information will be sent to "this_page.asp" through the url (see pageís url).

Example2: URL
You can just type in the parameter and its value directly in the address bar. The format is as follow :

page_name.asp ? parameter = value [& parameter = value ...]

this_page.asp?customer_name=Linawaty&customer_password=password

Either way, all you have to do is to catch that variable as follow :

<%
response.write "Customer Name : " & request.form("customer_name")
%>

Note that you can store that data into a variable first.

<%
Dim password
Password = request.form("customer_password")
response.write "Customer Password : " & password
%>

Also please note that a "password" fieldís data will be sent as if it is text data. The "***" or "ooo" while typing is for visual security only. You still can only view it in the url.


3. Request.servervariables("predefined_server_variable")
Unlike the other two above, you donít have to get some values first before retrieving server variables. All these information are located at server, available for request anytime you need it, such as :

a. browser information
<%=request.servervariables("HTTP_USER_AGENT")%>

b. Local IP address
<%=request.servervariables("LOCAL_ADDR")%>

c. URL
<%=request.servervariables("URL")%>

d. Request method
<%=request.servervariables("REQUEST_METHOD")%>

e. File name
<%=request.servervariables("SCRIPT_NAME")%>

You can also loop through all of the server variables like this:

<%
for each x in Request.ServerVariables
response.write x & "<br>"
next
%>


ASP Site @ BellaOnline
View This Article in Regular Layout

Content copyright © 2013 by Linawaty. All rights reserved.
This content was written by Linawaty. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.



| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor