All Packages Class Hierarchy This Package Previous Next Index
Class WebSite.Servlet.Server
java.lang.Object
|
+----WebSite.Servlet.Server
- public final class Server
- extends Object
The Server class implements access to WebSite server-related data items.
It is a purely static class, and cannot be instantiated.
- See Also:
- Client, Form, Request, Response, Session
-
constructURL(String)
- Constructs a complete URL for this server, given the URL path
portion.
-
escapeURL(String)
- Converts a string into "URL-escaped" format.
-
fileToURLPath(String)
- File path to URL ("reverse") mapping.
-
getAdminEmail()
- Gets the email address of the WebSite server administrator.
-
getContentType(String)
- Get the media content type for the given file name.
-
getDebugFlag()
- Gets the state of WebSite's "back-end debug tracing" option.
-
getGMTOffset()
- Gets the GMT offset in seconds, negative is West of GMT.
-
getHTTPTimeString()
- Get an HTTP format date/time string representing the current time.
-
getHTTPTimeString(long)
- Get an HTTP format date/time string.
-
getInstPath()
- Gets the physical path to the WebSite server installation root.
-
getName()
- Gets the internet (DNS) name of the server.
-
getPort()
- Gets the IP port number of the server.
-
getProduct()
- Gets the Website server product identification and version.
-
getTempName()
- Returns a guaranteed unique temporary filename.
-
getTempPath()
- Gets the physical path of the directory used to store temporary
files.
-
getVariable(String)
- Gets a server-internal variable by "CGI" name.
-
getVersion()
- Gets the version of the server API interface.
-
laterThan(String, String)
- Compare times in HTTP date/time string format.
-
logMessage(String)
- Logs a message to the server logfile, and on Windows NT, to the
server's application event log.
-
normalizeURL(String)
- Removes redundant or unsafe syntax from a URL path.
-
unescapeURL(String)
- Removes "URL escaping" from a string.
-
URLToFilePath(String, boolean)
- URL to file path mapping.
getProduct
public static native String getProduct()
- Gets the Website server product identification and version.
getVersion
public static native String getVersion()
- Gets the version of the server API interface.
getName
public static native String getName()
- Gets the internet (DNS) name of the server. This may be used to manufacture
URLs that reference the server. NOTE: If WebSite is running in
"multi-homed" mode, this string will contain the DNS name of the
identity on which the current HTTP request was received.
getPort
public static native int getPort()
- Gets the IP port number of the server. This may be used to manufacture
URLs that reference the server. NOTE: This port number will
differ depending on whether the HTTP request was received via an
SSL connection or not.
getAdminEmail
public static native String getAdminEmail()
- Gets the email address of the WebSite server administrator. This may be
used to build "mailto:" URLs, for example.
getDebugFlag
public static native boolean getDebugFlag()
- Gets the state of WebSite's "back-end debug tracing" option. This may be
used to enable diagnostic features of your Java servlet.
getGMTOffset
public static native int getGMTOffset()
- Gets the GMT offset in seconds, negative is West of GMT. For example,
the GMT offset for US Pacific Standard Time (PST, 8hr west) is
-28800.
getTempPath
public static native String getTempPath()
- Gets the physical path of the directory used to store temporary
files. You may use this as known existing directory in which to
create your temporary files.
getTempName
public static native String getTempName()
- Returns a guaranteed unique temporary filename. You can use this
in combination with the temp directory returned from getTempPath()
to construct (e.g.) a File object.
getInstPath
public static native String getInstPath()
- Gets the physical path to the WebSite server installation root. This is
the directory in which httpd32.exe is stored.
logMessage
public static native void logMessage(String msg)
- Logs a message to the server logfile, and on Windows NT, to the
server's application event log.
getVariable
public static native String getVariable(String name)
- Gets a server-internal variable by "CGI" name.
This method is provided for users who are migrating from Microsoft
ISAPI or Standard CGI to WebSite servlets. It simply provides a
way to access request, response, client, and server variables
using CGI-style "environment variable" names. This is WebSite's
WSAPI superset of the variables supported by ISAPI and most CGI
interfaces. Compatibility names have been provided as well.
Also note that the names used here are the "NCSA" style names, for maximum
compatility with ported applications. Name matching is caseless.
Supported Variables
| Variable Name |
Description |
| Server Information |
| DEBUG_MODE |
If WebSite's API/CGI tracing switch is on, this is "YES", otherwise it is "NO" |
| DOCUMENT_ROOT |
The physical directory path corresponding to the URL "/" for the current request. May vary if multi-homing is in use. |
| GATEWAY_INTERFACE |
The name and version of the gateway interface (e.g. "WSAPI/1.1") |
| GMT_OFFSET |
Offset of local time from GMT, seconds, negative west of GMT (PST is -28800, 8 hours west) |
| SERVER_ADMIN |
The email address of the server's administrator |
| SERVER_NAME |
The server's current hostname (will vary if multi-homing is used) |
| SERVER_PORT |
The TCP port on which the server received the current request (different ports are used for SSL and "normal"). |
| SERVER_PORT_SECURE |
The TCP port used by the server for "secure" (SSL) requests. This is not necessarily the port on which the current request was received. |
| SERVER_PROTOCOL |
The name and version of the server's protocol ("HTTP/1.0") |
| SERVER_SOFTWARE |
The name and version of the server software (e.g. "WebSitePro/2.0") |
| Client Info |
| HTTP_ACCEPT |
List of media content types (and possibly Q-values) that the client will accept |
| HTTP_ACCEPT_LANGUAGE |
List of languages that the client will accept |
| HTTP_FROM |
Email address of the client user (not currently supported by browsers) |
| HTTP_KEEP_ALIVE |
If the client supports keep-alive, this will be YES, otherwise it will be NO |
| HTTP_USER_AGENT |
The name and version of the client (browser) software |
| REMOTE_ADDR |
The IP address of the remote (client) host or proxy gateway. |
| REMOTE_HOST |
The DNS hostname of the remote (client) host (only if DNS reverse lookup is enabled, else this is identical to REMOTE_ADDR) |
| Client Authentication |
(present only if client sends authentication data)
|
| AUTH_NAME |
The realm from which user and group names are taken. WebSite supports multiple realms. |
| AUTH_TYPE |
The authentication type. Currently always "BASIC" |
AUTH_USER REMOTE_USER |
The username furnished with the authentication data |
| AUTH_PASSWORD |
The password furnished with the authentication data |
| LOGON_USER |
The username of the Windows NT native account under which this API generator is running. The current version of WebSite Pro runs all API extensions under a single native NT account. Not applicable on Windows 95. |
| Request Info |
| URL |
The decoded URL path for the request, including any "extra path" information. Does not include the host name, nor any query string or URL parameters. |
| CONTENT_LENGTH |
Length in bytes of data sent with the request (e.g., form data) |
| CONTENT_TYPE |
Media content type of data sent with the request (e.g. multipart/form-data) Includes parameters such as boundary strings. |
| HTTP_REQUEST_RANGE |
Range spec(s) sent with request. See current HTTP byte-range spec for details. |
| PATH_INFO |
"Extra" path information from the URL, also known as the "logical path" |
| PATH_TRANSLATED |
The translation of PATH_INFO to a physical path, using the current mapping. May vary if multi-homing is in use. |
| QUERY_STRING |
Data from the URL that follows the "?" in its raw original form |
| QUERY_STRING_UNESCAPED |
Translation of QUERY_STRING from raw to final form (plus to space and URL unescaping) |
| REQUEST_METHOD |
The HTTP method specified with the request (e.g., "GET", "POST") |
REFERER HTTP_REFERER |
The complete URL of the document that contained the current URL as a hyperlink. This may not be present. Some browsers report inconsistent Referer: information. |
| SCRIPT_NAME |
The URL path of the WSAPI extension, suitable for making self-referencing URLs |
| HTTP Extra Headers |
Any header not assigned to one of the above variables may be accessed by it's header label, or as part of the ALL_HTTP list (provided for ISAPI compatibility) |
| <extra-header-name> |
Returns the value of that header. For example "HTTP_Cookie" will get the cookie string sent with the request. Useful with SHTTP. |
| ALL_HTTP |
All HTTP headers that are not assigned to one of the above variables. These variables are of the form HTTP_ for compatibility with ISAPI. The headers consist of a linefeed-separated list of <name>=<value> pairs. |
- Parameters:
- name - The CGI-style name of the variable to get. See the table
above.
constructURL
public static native String constructURL(String path)
- Constructs a complete URL for this server, given the URL path
portion. The returned URL has a scheme of http:// or
https:// (if the connection is using SSL). The host name
and port number depend on the server/DNS identity and the port
via which the current request arrived. If the port number is
80 (or 443 for SSL) the port component is omitted from the URL.
- Parameters:
- path - The path/name for which the complete URL will be
constructed
escapeURL
public static native String escapeURL(String raw)
- Converts a string into "URL-escaped" format. The conversion is
done according to the HTTP/1.0 specification. Returns the
escaped string.
- Parameters:
- raw - the string the is to be escaped
- See Also:
- unescapeURL
unescapeURL
public static native String unescapeURL(String esc)
- Removes "URL escaping" from a string. The conversion is
done according to the HTTP/1.0 specification. Returns the
unescaped string.
- Parameters:
- esc - the escaped string
- See Also:
- escapeURL
fileToURLPath
public static native String fileToURLPath(String path)
- File path to URL ("reverse") mapping. The opposite of
URLToFilePath(). Returns a string containing
an equivalent URL pathname given a physical file pathname.
Note: If the file/URL mappings in effect are such that
more than one URL path translates to the given file path, the
results are unpredictable. The returned URL will be valid, however
it may not be the one you expected.
- Parameters:
- path - the file pathname to translate
- See Also:
- URLToFilePath
URLToFilePath
public static native String URLToFilePath(String path,
boolean doIndex)
- URL to file path mapping. The opposite of fileToURLPath().
Returns a string containing the equivalent physical file pathname
given the URL path. Note that the returned pathname contains the
native Win32 path separators, and may be a UNC pathname
(e.g., \\host\share\....
Directory URL handling:
If the URL translates to a physical directory, this method can
optionally resolve the "default document" in that directory.
setting the doIndex parameter to true enables
this feature. The test to see if the URL resolves to a directory
is rigorous (the attributes of the target are checked to see
that it is a directory). Next, a search is made, according to the
default document settings, for the existence of a default document.
If it exists and is usable (readable for documents, executable for
API, servlets, CGI, etc.), the default documetn name will be
appended to the path.
- Parameters:
- path - the URL path to translate
- doIndex - True to do default document processing
- See Also:
- fileToURLPath
normalizeURL
public static native String normalizeURL(String path)
- Removes redundant or unsafe syntax from a URL path. Returns
a string with redundant and/or unsafe syntax removed. Removes
multiple repeated /, changes ./ to /,
removes things like foo/../ and trailing /.
This function is useful when comparing a URL to a reference.
If the URL has spurious syntax, the match may fail even though
the URL can be translated to a valid file path.
You can compare the returned URL against the original, and
if different, redirect the client with the cleaned-up URL path.
The server does this on simple GET requests, so for
those you will not see spurious syntax in the first place.
- Parameters:
- path - the URL path to be cleaned up as needed
getContentType
public static native String getContentType(String path)
- Get the media content type for the given file name. Returns a
string containing the media ("MIME") content type, given a
file name. The information is taken from WebSite's content-type
mapping table, which uses the file's "extension" as the key.
If the file name does not contain a period, the "default"
content type (usually application/octet-stream) is
returned.
Note: WebSite uses server-side content types, which
always start with wwwserver/.... If you get one of these
types back, do not use it in your response.
- Parameters:
- name - file name for which content-type is desired
getHTTPTimeString
public static native String getHTTPTimeString(long time)
- Get an HTTP format date/time string. Returns a string which
contains an HTTP compliant date/time string, given the number
of milliseconds since January 1, 1970 (the Java epoch). You can
use the getHTTPTimeString() variant as a shortcut
if you want a date/time string for "now".
The format of the string is in the "recommended" format of
HTTP/1.0 and mandated for the Date: header in HTTP/1.1.
For example:
Sun, 06 Nov 1994 08:49:37 GMT
- Parameters:
- time - milliseconds since January 1, 1970
getHTTPTimeString
public static native String getHTTPTimeString()
- Get an HTTP format date/time string representing the current time.
Returns a string which
contains an HTTP compliant date/time string for the current time.
The format of the string is in the "recommended" format of
HTTP/1.0 and mandated for the Date: header in HTTP/1.1.
For example:
Sun, 06 Nov 1994 08:49:37 GMT
laterThan
public static native boolean laterThan(String t1,
String t2)
- Compare times in HTTP date/time string format. This method is
provided so that you can implement your own "If Modified Since"
support. You can use the getHttpTimeString(...) methods
to get properly formatted string(s).
- Parameters:
- t1 - HTTP date/time to test
- t2 - HTTP date/time to test against
- Returns:
- only if t1 is later than t2.
All Packages Class Hierarchy This Package Previous Next Index