When discussing the content of the request object, one of the collections to be studied is the ServerVariables collection. This collection contains a combination of two values, one that accompanies the page request from the client to the server's HTTP header, and the value provided by the server itself when it receives the request.
The Self-References page
The value returned in the ServerVariables collection contains the details of the Web server and the path information for the current page. You can use this information to create a page anywhere. For example, to create a "self reference" page, this page can call itself to complete another task, we can use the following code:
<FORM ACTION=”<% = Request.ServerVariables(“PATH_INFO”) %>” METHOD=”POST”>
The same effect can be obtained with the "script_name" value of http:
<FORM ACTION=”<% = Request.ServerVariables(“SCRIPT_NAME”) %>” METHOD=”POST”>
Using the element to open a different page, you can use:
...
<%
strFullPath = Request.ServerVariables(“PATH_INFO”)
‘Strip off the file name
strPathOnly = Left(strFullPath, InStrRev(strFullPath, “/”))
strNextPage = strPathOnly & “pages/next_page.asp”
%>
...
<A HREF=”<% = strNextPage %>”>Next Page</A>
...
These instances work correctly even if the name or location of the original page changes, because the path information for the current page is used (of course, the second example fails when the name of the detached target page changes).
In other words, if you automatically create URLs for a child session of a search engine, you can collect some of the servervariable values:
strFullURL = http:// & Request.ServerVariables(“LOCAL_ADDR”) _ & “:” &Request.ServerVariables(“SERVER_PORT”) _ & Request.ServerVariables(“PATH_INFO”)
This will create a complete URL that includes the port number (in this case, not the standard value 80). For example, the result might be:
Http://194.74.60.254:1768/thispath/thispage.asp