Table of Contents | Previous | Next | Index


server

Contains global data for the entire server.

Server-side object

Implemented in

NES 2.0

Created by

The JavaScript runtime engine on the server automatically creates a single server object to store information common to all JavaScript applications running on the web server.

Description

The JavaScript runtime engine on the server creates a server object when the server starts and destroys it when the server stops. Every application on a server shares the same server object. Use the server object to maintain global data for the entire server. Many applications can run on a server simultaneously, and the server object lets them share information.

The runtime engine creates a server object for each distinct Netscape HTTPD process running on the server.

The properties listed below are read-only properties that are initialized automatically when a server object is created. These properties provide information about the server process. In addition to these predefined properties, you can create custom properties.

You can lock the server object to ensure that different applications do not change its properties simultaneously. When one application locks the server object, other applications must wait before they can lock it.

Property Summary

Property Description
host

String specifying the server name, subdomain, and domain name.

hostname

String containing the full hostname of the server, including the server name, subdomain, domain, and port number.

port

String indicating the port number used for the server.

protocol

String indicating the communication protocol used by the server.

Method Summary

Method Description
lock

Obtains the lock.

unlock

Releases the lock.

In addition, this object inherits the watch and unwatch methods from Object.

Examples

The following example displays the values of the predefined server object properties:

<P>server.host = <SERVER>write(server.host);</SERVER>
<BR>server.hostname = <SERVER>write(server.hostname);</SERVER>
<BR>server.protocol = <SERVER>write(server.protocol);</SERVER>
<BR>server.port = <SERVER>write(server.port);</SERVER>
The preceding code displays information such as the following:

server.host = www.myWorld.com
server.hostname = www.myWorld.com:85
server.protocol = http:
server.port = 85

See also

client, project, request


host

A string specifying the server name, subdomain, and domain name.

Property of

server

Read-only

Implemented in

NES 2.0

Description

The host property specifies a portion of a URL. The host property is a substring of the hostname property. The hostname property is the concatenation of the host and port properties, separated by a colon. When the port property is 80 (the default), the host property is the same as the hostname property.

See Section 3.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the hostname and port.

See also

server.hostname, server.port, server.protocol


hostname

A string containing the full hostname of the server, including the server name, subdomain, domain, and port number.

Property of

server

Read-only

Implemented in

NES 2.0

Description

The hostname property specifies a portion of a URL. The hostname property is the concatenation of the host and port properties, separated by a colon. When the port property is 80 (the default), the host property is the same as the hostname property.

See Section 3.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the hostname and port.

See also

server.host, server.port, server.protocol


lock

Obtains the lock. If another thread has the lock, this method waits until it can get the lock.

Method of

server

Implemented in

NES 2.0

Syntax

lock()

Parameters

None

Returns

Nothing.

Description

You can obtain a lock for an object to ensure that different clients do not access a critical section of code simultaneously. When an application locks an object, other client requests must wait before they can lock the object.

Note that this mechanism requires voluntary compliance by asking for the lock in the first place.

See also

Lock, server.lock


port

A string indicating the port number used for the server.

Property of

server

Read-only

Implemented in

NES 2.0

Description

The port property specifies a portion of the URL. The port property is a substring of the hostname property. The hostname property is the concatenation of the host and port properties, separated by a colon.

The default value of the port property is 80. When the port property is set to the default, the values of the host and hostname properties are the same.

See Section 3.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the port.

See also

server.host, server.hostname, server.protocol


protocol

A string indicating the communication protocol used by the server.

Property of

server

Read-only

Implemented in

NES 2.0

Description

The protocol property specifies the beginning of the URL, up to and including the first colon. The protocol indicates the access method of the URL. For example, a protocol of "http:" specifies HyperText Transfer Protocol.

The protocol property represents the scheme name of the URL. See Section 2.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the protocol.

See also

server.host, server.hostname, server.port


unlock

Releases the lock.

Method of

server

Implemented in

NES 2.0

Syntax

unlock()

Parameters

None.

Returns

False if it fails; otherwise, true. Failure indicates an internal JavaScript error or that you attempted to unlock a lock that you don't own.

Description

If you unlock a lock that is unlocked, the resulting behavior is undefined.

See also

Lock, server.unlock


Table of Contents | Previous | Next | Index

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

Copyright © 1998 Netscape Communications Corporation

Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use