[This is preliminary documentation and subject to change]
The #echo directive instructs the Web server to display the value of a server variable. You must surround a directive with HTML comment delimiters.
By default, this directive can be used only in STM pages; it cannot be used in ASP pages. For ASP pages, you can access the server variables by using the ServerVariables collection.
<!-- #echo var =VariableName-->
VariableName
Specifies the name of the variable whose value you want to insert. The variable can be one of the following:
| Variable | Meaning |
| ALL_HTTP | All HTTP headers that were not already parsed into one of the other variables described in this table. These variables are of the form HTTP_header field name. The headers consist of a null-terminated string with the individual headers separated by carriage return line feeds. |
| AUTH_TYPE | This contains the type of authentication used. For example, the string will be "Basic" if Basic authentication is used, and it will be "integrated Windows authentication" for integrated authentication. Other authentication schemes will have other strings. Because new authentication types can be added to the Web server, it is not possible to list all the string possibilities. If the string is empty, then no authentication is used. |
| AUTH_PASSWORD | The value entered in the client's authentication dialog box. This variable is available only if Basic authentication is used. |
| AUTH_USER | The value entered in the client's authentication dialog box. |
| CONTENT_LENGTH | The number of bytes that the script can expect to receive from the client. |
| CONTENT_TYPE | The content type of the information supplied in the body of a POST request. |
| DOCUMENT_NAME | The current file name. |
| DOCUMENT_URI | The virtual path to the current document. |
| DATE_GMT | The current date in Greenwich Mean Time (GMT). |
| DATE_LOCAL | The current date in the local time zone. |
| GATEWAY_INTERFACE | The revision of the CGI specification used by the Web server. The revision is returned in the format CGI/revision. |
| HTTP_ACCEPT | Special-case HTTP header. Values of the accept fields are
concatenated, and separated by a comma (,). For example, if the
following lines are part of the HTTP header:
the HTTP_ACCEPT variable will have a value of:
|
| LAST_MODIFIED | The date that the current document was last modified. |
| PATH_INFO | Additional path information, as given by the client. This consists of the trailing part of the URL after the script name, but before the query string, if any. |
| PATH_TRANSLATED | This is the value of PATH_INFO, but with any virtual path expanded into a directory specification. |
| QUERY_STRING | The information that follows the question mark (?) in the URL that referenced this script. |
| QUERY_STRING_UNESCAPED | Unescaped version of the query string; that is, a version that is not URL encoded. |
| REMOTE_ADDR | The IP address of the client or agent of the client (for example, gateway or firewall) that sent the request. |
| REMOTE_HOST | The host name of the client or agent of the client (for example, gateway or firewall) that sent the request. IIS 2.0 and 3.0 returned an IP address for this parameter. |
| REMOTE_USER | This contains the user name of the client if the client went through authentication by the server. This comes back as an empty string if Anonymous Access is enabled on the application. |
| REQUEST_METHOD | The HTTP request method. |
| SCRIPT_NAME | The name of the script program being executed. |
| SERVER_NAME | The server's host name, or IP address, as it should appear in self-referencing URLs. |
| SERVER_PORT | The TCP/IP port on which the request was received. |
| SERVER_PORT_SECURE | A string of either 0 or 1. If the request is being handled on the secure port, this will be 1. Otherwise, it will be 0. |
| SERVER_PROTOCOL | The name and version of the information retrieval protocol relating to this request. This is usually HTTP/1.0. The protocol is returned in the format name/version. |
| SERVER_SOFTWARE | The name and version of the Web server answering the request. The server information is returned in the format name/version. |
| URL | Gives the base portion of the URL. Parameter values will not be included. The value is determined when the Web server parses the URL from the header. |
The file containing this directive must use a file name extension that is mapped to the SSI interpreter; otherwise, the Web server will not process the directive. By default, the file name extensions .stm, .shtm, and .shtml are mapped to the SSI interpreter (ssinc.dll).
An STM page using the #echo directive must be run by itself, or by calling it from an ASP page with Response.Redirect. Calling an STM page from an ASP page with Server.Transfer, Server.Execute, or #include will not work because that would force the STM page to go through asp.dll instead of through ssinc.dll.
If you have the IIS snap-in installed, you can modify default extension mappings and add new mappings; see Setting Application Mappings. Since you cannot map a file extension to more than one executable, you cannot use this directive in ASP files. ASP files are already mapped to the asp.dll and must stay that way.
This example uses the #echo directive to insert a URL into the ACTION value of a FORM statement.
--- Echo.asp ---
<FORM NAME="RunEcho" METHOD="POST" ACTION="Echo.asp">
<INPUT TYPE="SUBMIT" VALUE="Run the #echo Directive" NAME="RunEcho">
</FORM>
<%
If Len(Request.Form("RunEcho")) Then
Response.Redirect("Echo.stm?Echo.asp")
End If
%>
--- Echo.stm ---
<H3>Inside Echo.stm</H3> AUTH_TYPE is <!-- #echo var="AUTH_TYPE"--><BR> <FORM NAME="Return" METHOD="POST" ACTION="<!-- #echo var="QUERY_STRING"-->"> <INPUT TYPE="SUBMIT" VALUE="Return to Previous Page" NAME="Return"> </FORM>