Table of Contents | Previous | Next | Index


request

Contains data specific to the current client request.

Server-side object

Implemented in

NES 2.0

Created by

The JavaScript runtime engine on the server automatically creates a request object for each client request.

Description

The JavaScript runtime engine on the server creates a 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:

Use escape to encode non-alphanumeric values in the URL string.

You can also create custom properties for the request object.

Property Summary

Property Description
agent

Provides name and version information about the client software.

imageX

The horizontal position of the mouse pointer when the user clicked the mouse over an image map.

imageY

The vertical position of the mouse pointer when the user clicked the mouse over an image map.

inputName

Represents an input element on an HTML form. (There is not a property whose name is inputName. Rather, each instance of request has properties named after each input element.)

ip

Provides the IP address of the client.

method

Provides the HTTP method associated with the request.

protocol

Provides the HTTP protocol level supported by the client's software.

Method Summary

This object inherits the watch and unwatch methods from Object.

Examples

Example 1. This example displays the values of the predefined properties of the request object. In this example, an HTML form is defined as follows:

<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>
The following code displays the values of the request object properties that are created when the form is submitted:

agent = <SERVER>write(request.agent)</SERVER><BR>
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>
When it executes, this code displays information similar to the following:

agent = "Mozilla/2.0 (WinNT;I)"
ip = "165.327.114.147"
method = "GET"
protocol = "HTTP/1.0"
lastName = "Schaefer"
firstName = "Jesse"
Example 2. The following example creates the 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>.

See also

client, project, server


agent

Provides name and version information about the client software.

Property of

request

Read-only

Implemented in

NES 2.0

Description

The 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:

Examples

The following example displays client information for Navigator 2.0 on Windows NT:

write(request.agent)
\\Displays "Mozilla/2.0 (WinNT;I)"
The following example evaluates the 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>

See also

request.ip, request.method, request.protocol


imageX

The horizontal position of the mouse pointer when the user clicked the mouse over an image map.

Property of

request

Read-only

Implemented in

NES 2.0

Description

The ISMAP attribute of the 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.

Examples

Suppose you define the following image map:

<A HREF="mapchoice.html">
<IMG SRC="images\map.gif" WIDTH=599 WIDTH=424 BORDER=0 ISMAP
ALT="SANTA CRUZ COUNTY">
</A>
Note the 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.

See also

request.imageY


imageY

The vertical position of the mouse pointer when the user clicked the mouse over an image map.

Property of

request

Read-only

Implemented in

NES 2.0

Description

The ISMAP attribute of the 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.

Examples

See example for imageX.

See also

request.imageX


inputName

Represents an input element on an HTML form.

Property of

request

Read-only

Implemented in

NES 2.0

Description

Each input element in an HTML form corresponds to a property of the 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.

Examples

The following HTML source creates the 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>

ip

Provides the IP address of the client.

Property of

request

Read-only

Implemented in

NES 2.0

Description

The IP address is a set of four numbers between 0 and 255, for example, 198.217.226.34. You can use the IP address to authorize or record access in certain situations.

Examples

In the following example, the 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>

See also

request.agent, request.method, request.protocol


method

Provides the HTTP method associated with the request.

Property of

request

Read-only

Implemented in

NES 2.0

Description

The value of the 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.

Examples

The following example executes the 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>

See also

request.agent, request.ip, request.protocol


protocol

Provides the HTTP protocol level supported by the client's software.

Property of

request

Read-only

Implemented in

NES 2.0

Description

For HTTP 1.0, the protocol value is "HTTP/1.0". Use the protocol property to determine the proper response to a request.

Examples

In the following example, the currentProtocol function executes if request.protocol evaluates to "HTTP/1.0".

<SERVER>
if (request.protocol=="HTTP/1.0"
   currentProtocol()
else
   unknownProtocol()
</SERVER>

See also

request.agent, request.ip, request.method


Table of Contents | Previous | Next | Index

Last Updated: 11/13/98 10:23:43

Copyright � 1998 Netscape Communications Corporation