ASP Tutorials - Herong's Tutorial Examples - Version 5.10, by Dr. Herong Yang
"request" Object - Receiving Data from Client
This section provides a tutorial example on how to use the 'request' object provided by the ASP programming interface to receive data from the client, the Web browser.
The request object is a very rich object. It contains everything the client sends to the server:
The following ASP page shows how to access the property and collections of the request object.
<script language="vbscript" runat="server"> ' request_test.asp ' Copyright (c) 2002 by Dr. Herong Yang ' This program shows how to use the "request" object. ' response.write("<html><body>") response.write("<b>Tests on the request object</b>:<br/>") response.write("Total bytes = " & request.TotalBytes & "<br/>") set c = request.QueryString response.write("QueryString.Count = " & c.Count & "<br/>") for each v in c response.write( v & " = " & c.Item(v) & "<br/>") next set c = request.Form response.write("Form.Count = " & c.Count & "<br/>") for each v in c response.write( v & " = " & c.Item(v) & "<br/>") next set c = request.ServerVariables response.write("ServerVariables.Count = " & c.Count & "<br/>") for each v in c response.write( v & " = " & c(v) & "<br/>") next set c = request.Cookies response.write("Cookies.Count = " & c.Count & "<br/>") for each v in c response.write( v & " = " & c(v) & "<br/>") next set c = request.ClientCertificate response.write("ClientCertificate.Count = " & c.Count & "<br/>") for each v in c response.write( v & " = " & c(v) & "<br/>") next response.write("</body></html>") </script>
Tests on the request object: Total bytes = 0 QueryString.Count = 0 Form.Count = 0 ServerVariables.Count = 49 ALL_HTTP = HTTP_ACCEPT:*/* HTTP_ACCEPT_LANGUAGE:en-us HTTP_CONNECTION:... ALL_RAW = Accept: */* Accept-Language: en-us Connection: Keep-Alive ... APPL_MD_PATH = /LM/W3SVC/1/ROOT APPL_PHYSICAL_PATH = c:\inetpub\wwwroot\ AUTH_PASSWORD = AUTH_TYPE = AUTH_USER = CERT_COOKIE = CERT_FLAGS = CERT_ISSUER = CERT_KEYSIZE = CERT_SECRETKEYSIZE = CERT_SERIALNUMBER = CERT_SERVER_ISSUER = CERT_SERVER_SUBJECT = CERT_SUBJECT = CONTENT_LENGTH = 0 CONTENT_TYPE = GATEWAY_INTERFACE = CGI/1.1 HTTPS = off HTTPS_KEYSIZE = HTTPS_SECRETKEYSIZE = HTTPS_SERVER_ISSUER = HTTPS_SERVER_SUBJECT = INSTANCE_ID = 1 INSTANCE_META_PATH = /LM/W3SVC/1 LOCAL_ADDR = 127.0.0.1 LOGON_USER = PATH_INFO = /request_test.asp PATH_TRANSLATED = c:\inetpub\wwwroot\request_test.asp QUERY_STRING = REMOTE_ADDR = 127.0.0.1 REMOTE_HOST = 127.0.0.1 REMOTE_USER = REQUEST_METHOD = GET SCRIPT_NAME = /request_test.asp SERVER_NAME = localhost SERVER_PORT = 80 SERVER_PORT_SECURE = 0 SERVER_PROTOCOL = HTTP/1.1 SERVER_SOFTWARE = Microsoft-IIS/5.0 URL = /request_test.asp HTTP_ACCEPT = */* HTTP_ACCEPT_LANGUAGE = en-us HTTP_CONNECTION = Keep-Alive HTTP_HOST = localhost HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; MSNIA; Windows NT... HTTP_COOKIE = ASPSESSIONIDQQGQQVFQ=DFPLLCDACFFBCIBMCKALNNMK HTTP_ACCEPT_ENCODING = gzip, deflate Cookies.Count = 0 ClientCertificate.Count = 0
A couple of interesting things to note here:
If you request this ASP page with the following url:
You will see the following changes in the output:
Tests on the request object: QueryString.Count = 2 Name = Bill Smith Country = Canada ServerVariables.Count = 49 ... QUERY_STRING = Name=Bill+Smith&Country=Canada
What happens here is:
Last update: 2002.
Table of Contents