|
The ServerVariables collection retrieves the values of environment variables.
Request.ServerVariables(variable)
variable
This specifies the name of the server environment variable to retrieve. It can be one of the values from the following table:
Value |
Description |
ALL_RAW |
All headers in raw form as sent by the client. |
APPL_MD_PATH* |
Retrieves the metabase path for the application. |
APPL_PHYSICAL_PATH |
Retrieves the physical path corresponding to the metabase path. |
ASP_VERSION |
Version number of the Sun Chili!Soft ASP server. |
ASP_VERSION_MAJOR |
The major version number of the Sun Chili!Soft ASP server. |
ASP_VERSION_MINOR |
The minor version number of the Sun Chili!Soft ASP server. |
ASP_OS |
The operating system the server is running on. |
ASP_LICENSE |
License information for the Sun Chili!Soft ASP server. |
AUTH_PASSWORD |
The password corresponding to REMOTE_USER as supplied by the client. |
AUTH_TYPE |
If the server supports user authentication and the script is protected, this is the protocol-specific authentication method used to validate the user. |
AUTH_USER |
Raw authenticated user name. |
CERT_COOKIE* |
Unique ID for the client certificate, returned as a string. |
CERT_FLAGS* |
bit0 is set to 1 if the client certificate is present. bit1 is set to 1 if the Certifying Authority of the client certificate is invalid (not in the list of recognized CA on the server). |
CERT_ISSUER* |
Issuer field of the client certificate. |
CERT_KEYSIZE* |
Number of bits in the Secure Sockets Layer connection key size, for example, 128. |
CERT_SECRETKEYSIZE* |
Number of bits in the server certificate private key, for example 1024. |
CERT_SERIALNUMBER* |
Serial number field of the client certificate. |
CERT_SERVER_ISSUER* |
Issuer field of the server certificate. |
CERT_SERVER_SUBJECT* |
Subject field of the server certificate. |
CERT_SUBJECT* |
Subject field of the client certificate. |
CONTENT_LENGTH |
The length of content as given by the client. |
CONTENT_TYPE |
The data type of the content in queries that have attached information, such as HTTP GET, POST, and PUT. |
GATEWAY_INTERFACE |
The revision of the CGI specification used by the server. Format: CGI/revision. |
HTTP_<HeaderName> |
The value stored in the header HeaderName. Any header other than those listed in this table must be prefixed by "HTTP_" for the ServerVariables collection to retrieve its value. The server interprets any underscore (_) characters in HeaderName as dashes in the actual header. For example, if you specify HTTP_MY_HEADER, the server searches for MY-HEADER. |
HTTPS |
Returns "on" if the request came in through a secure channel or "off" if the request is for a non-secure channel. |
HTTPS_KEYSIZE |
Number of bits in Secure Sockets Layer key size, for example, 128. |
HTTPS_SECRET_KEYSIZE |
Number of bits in the server certificate private key, for example, 1024. |
HTTPS_SERVER_ISSUER |
Issuer field of the server certificate. |
HTTPS_SERVER_SUBJECT |
Subject field of the server certificate. |
INSTANCE_ID |
The ID for the instance in textual format. If the instance ID is 1, it appears as a string. Under IIS you can use this variable to retrieve the ID of the Web-server instance (in the metabase) to which the request belongs. |
INSTANCE_META_PATH* |
The metabase path for the instance of IIS that responds to the request. |
LOCAL_ADDR |
Returns the Server Address on which the request came in. This is important on multi-homed machines where there can be multiple IP addresses bound to a machine and you want to find out which address the request used. |
LOGON_USER |
The Windows account the client user is logged into. Note Not supported by Sun Chili!Soft ASP for UNIX. |
PATH_INFO |
The extra path information, as given by the client. Scripts can be accessed by using their virtual path and the PATH_INFO server variable. If this information comes from a URL, it is decoded by the server before it is passed to the script. |
PATH_TRANSLATED |
A translated version of PATH_INFO that takes the path and performs any virtual to physical mapping. |
QUERY_STRING |
Query information in the string following the question mark (?) in the HTTP request. |
REMOTE_ADDR |
The IP address of the remote host making the request. |
REMOTE_HOST |
The name of the host making the request. If the server does not have this information, it will set REMOTE_ADDR and leave this empty. |
REMOTE_USER |
If the server supports user authentication and the script is protected, this is the username by which the user is authenticated. |
REQUEST_METHOD |
The method used to make the request. For HTTP, this would be GET, HEAD, POST, etc. |
SCRIPT_NAME |
A virtual path to the script being executed. This is used for self-referencing URLs. |
SERVER_NAME |
The server's host name, DNS alias, or IP address as it would appear in self-referencing URLs. |
SERVER_PORT |
The port number to which the request was sent. |
SERVER_PORT_SECURE |
A string that contains either 0 or 1. If the request is being handled on the secure port, then this will be 1; otherwise it will be 0. |
SERVER_PROTOCOL |
The name and revision of the information protocol. Format: protocol/revision. |
SERVER_SOFTWARE |
The name and version of the server software answering the request and running the gateway. Format: name/version. |
URL |
Gives the base portion of the URL. |
*These server variables are only valid when running Sun Chili!Soft ASP with Microsoft Internet Information Server. When using other Web servers they will always be empty.
If a client sends a header other than those specified in the preceding table, you can retrieve the value of the header by prefixing the header name with "HTTP_" in the call to Request.ServerVariables. For example, if the client sent the following header:
SomeNewHeader:SomeNewValue
you could retrieve SomeNewValue by using the following:
<% Request.ServerVariables("HTTP_SomeNewHeader") %>
You can use an iterator to loop through each server variable name. For example, the following script prints all of the server variables in a table:
<TABLE>
<TR><TH>Server Variable</TH><TH>Value</TH></TR>
<% for each name in Request.ServerVariables %>
<TR>
<TD><%= name %></TD>
<TD><%= Request.ServerVariables(name) %></TD>
</TR>
<% Next %>
</TABLE>
The following example demonstrates using Request.ServerVariables to insert the name of a server into a hyperlink:
<A HREF="http://<%= Request.ServerVariables("SERVER_NAME")%>
/scripts/MyPage.asp">Link to MyPage.asp</A>
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.