request
object for each client request.
request
object each time the client makes a request of the server. The runtime engine destroys the request
object after the server responds to the request, typically by providing the requested page.
The properties listed below are read-only properties that are initialized automatically when a request
object is created. In addition to these predefined properties, you can create custom properties to store application-specific data about the current request.
Custom properties.
You can create a property for the request
object by assigning it a name and a value. For example, you can create a request
property to store the date and time that a request is received so you can enter the date into the page content.
You can also create request
object properties by encoding them in a URL. When a user navigates to the URL by clicking its link, the properties are created and instantiated to values that you specify. The properties are valid on the destination page.
Use the following syntax to encode a request
property in a URL:
<A HREF="URL?propertyName=value&propertyName=value...">where:
URL
is the URL the page that will get the new request
properties.propertyName
is the name of the property you are creating.value
is the initial value of the new property.escape
to encode non-alphanumeric values in the URL string.
request
object.
watch
and unwatch
methods from Object
.
request
object. In this example, an HTML form is defined as follows:
<FORM METHOD="post" NAME="idForm" ACTION="hello.html">The following code displays the values of the
<P>Last name:
<INPUT TYPE="text" NAME="lastName" SIZE="20">
<BR>First name:
<INPUT TYPE="text" NAME="firstName" SIZE="20">
</FORM>
request
object properties that are created when the form is submitted:
agent = <SERVER>write(request.agent)</SERVER><BR>When it executes, this code displays information similar to the following:
ip = <SERVER>write(request.ip)</SERVER><BR>
method = <SERVER>write(request.method)</SERVER><BR>
protocol = <SERVER>write(request.protocol)</SERVER><BR>
lastName = <SERVER>write(request.lastName)</SERVER><BR>
firstName = <SERVER>write(request.firstName)</SERVER>
agent = "Mozilla/2.0 (WinNT;I)"Example 2. The following example creates the
ip = "165.327.114.147"
method = "GET"
protocol = "HTTP/1.0"
lastName = "Schaefer"
firstName = "Jesse"
requestDate
property and initializes it with the current date and time:
request.requestDate = new Date()Example 3. When a user clicks the following link, the
info.html
page is loaded, request.accessedFrom
is created and initialized to "hello.html"
, and request.formId
is created and initialized to "047"
.
Click here for
<A HREF="info.html?accessedFrom=hello.html&formId=047">
additional information</A>.
client
, project
, server
agent
property identifies the client software. Use this information to conditionally employ certain features in an application.
The value of the agent
property is the same as the value of the userAgent
property of the client-side navigator
object. The agent
property specifies client information in the following format:
codeName
/releaseNumber
(platform
; country
; platformIdentifier
)
The values contained in this format are the following:
codeName
is the code name of the client. For example, "Mozilla"
specifies Navigator.releaseNumber
is the version number of the client. For example, "2.0b4"
specifies Navigator 2.0, beta 4.platform
is the platform upon which the client is running. For example, "Win16"
specifies a 16-bit version of Windows, such as Windows 3.11.country
is either "I"
for the international release or "U"
for the domestic U.S. release. The domestic release has a stronger encryption feature than the international release.platformIdentifier
is an optional identifier that further specifies the platform. For example, in Navigator 1.1, platform
is "windows"
and platformIdentifier
is "32bit"
. In Navigator 2.0, both pieces of information are contained in the platform
designation. For example, in Navigator 2.0, the previous platform is expressed as "WinNT"
.write(request.agent)The following example evaluates the
\\Displays "Mozilla/2.0 (WinNT;I)"
request.agent
property and runs the oldBrowser
procedure for clients other than Navigator 2.0. If the browser is Navigator 2.0, the currentBrowser
function executes.
<SERVER>
var agentVar=request.agent
if (agentVar.indexOf("2.0")==-1)
oldBrowser()
else
currentBrowser()
</SERVER>
request.ip
, request.method
, request.protocol
IMG
tag indicates a server-based image map. When the user clicks the mouse with the pointer over an image map, the horizontal and vertical position of the pointer are returned to the server.
The imageX
property returns the horizontal position of the mouse cursor when the user clicks on an image map.
<A HREF="mapchoice.html">Note the
<IMG SRC="images\map.gif" WIDTH=599 WIDTH=424 BORDER=0 ISMAP
ALT="SANTA CRUZ COUNTY">
</A>
ISMAP
attribute that makes the image a clickable map. When the user clicks the mouse on the image, the page mapchoice.html
will have properties request.imageX
and request.imageY
based on the mouse cursor position where the user clicked.
request.imageY
IMG
tag indicates a server-based image map. When the user clicks the mouse with the pointer over an image map, the horizontal and vertical position of the pointer are returned to the server.
The imageY
property returns the vertical position of the mouse cursor when the user clicks on an image map.
imageX
.
request.imageX
request
object. The name of each of these properties is the name of the field on the associated form. inputName
is a variable that represents the value of the name
property of an input field on a submitted form. By default, the value of the JavaScript name
property is the same as the HTML NAME
attribute.
request.lastName
and the request.firstName
properties when idForm
is submitted:
<FORM METHOD="post" NAME="idForm" ACTION="hello.html">
<P>Last name:
<INPUT TYPE="text" NAME="lastName" SIZE="20">
<BR>First name:
<INPUT TYPE="text" NAME="firstName" SIZE="20">
</FORM>
indexOf
method evaluates request.ip
to determine if it begins with the string "198.217.226"
. The if
statement executes a different function depending on the result of the indexOf
method.
<SERVER>
var ipAddress=request.ip
if (ipAddress.indexOf("198.217.226.")==-1)
limitedAccess()
else
fullAccess()
</SERVER>
request.agent
, request.method
, request.protocol
method
property is the same as the value of the method
property of the client-side Form
object. That is, method
reflects the METHOD
attribute of the FORM
tag. For HTTP 1.0, the method
property evaluates to either "get"
or "post"
. Use the method
property to determine the proper response to a request.
postResponse
function if the method
property evaluates to "post"
. If method
evaluates to anything else, it executes the getResponse
function.
<SERVER>
if (request.method=="post")
postResponse()
else
getResponse()
</SERVER>
request.agent
, request.ip
, request.protocol
"HTTP/1.0"
. Use the protocol
property to determine the proper response to a request.
currentProtocol
function executes if request.protocol
evaluates to "HTTP/1.0"
.
<SERVER>
if (request.protocol=="HTTP/1.0"
currentProtocol()
else
unknownProtocol()
</SERVER>
request.agent
, request.ip
, request.method
Last Updated: 11/13/98 10:23:43