Online Shopping : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

27 of 34 people (79%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I get the currently running script name?

Mar 24th, 2009 18:05
chat alarab, Jerry Yoakum, Tony Liu, Nathan Wallace, Active Server Pages in 14 Days by Sanjaya Hettihewa with Kelly Held (ISBN 1575213303)


On page 292 of Active Server Pages in 14 Days under the "Accessing 
Server Variables" section there is a listing for the SCRIPT_NAME 
serverVariable.
"Files on a Web server are usually referenced relative to their 
document root directory.  SCRIPT_NAME contains the virtual pathname of 
the script called relative to the document root directory.  For 
example, if the document root directory is C:\Inetpub\wwwroot, all ASP 
scripts are stored in C:\Inetpub\wwwroot\cgi-bin\, and the ASP script 
HelloWorld.asp is called, the SCRIPT_NAME variable contains the value 
\cgi-bin\HelloWorld.asp.  The advantage of this variable is that it 
allows the ASP script to refer to itself.  This is handy if, somewhere 
in the output, the script's URL needs to be made into a hypertext link."
NOTE: I changed the filepath in the quote above to match the example 
below.
Here is an example ASP script that outputs all current ServerVariables:
========================================================================
<%@ LANGUAGE="VBSCRIPT" %>
<%
 Option Explicit
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>ServerVariables</TITLE>
</HEAD>
<BODY TopMargin="0" Leftmargin="0">
CONTENT_TYPE = <%=Request.ServerVariables("CONTENT_TYPE")%><BR>
PATH_INFO = <%=Request.ServerVariables("PATH_INFO")%><BR>
PATH_TRANSLATED = <%=Request.ServerVariables("PATH_TRANSLATED")%><BR>
QUERY_STRING = <%=Request.ServerVariables("QUERY_STRING")%><BR>
REMOTE_ADDR = <%=Request.ServerVariables("REMOTE_ADDR")%><BR>
REMOTE_HOST = <%=Request.ServerVariables("REMOTE_HOST")%><BR>
REQUEST_METHOD = <%=Request.ServerVariables("REQUEST_METHOD")%><BR>
SCRIPT_NAME = <%=Request.ServerVariables("SCRIPT_NAME")%><BR>
SERVER_NAME = <%=Request.ServerVariables("SERVER_NAME")%><BR>
SERVER_SOFTWARE = <%=Request.ServerVariables("SERVER_SOFTWARE")%>
</BODY>
</HTML>
========================================================================
Here is my output for the above ASP script:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CONTENT_TYPE = 
PATH_INFO = /cgi-bin/Default.asp
PATH_TRANSLATED = C:\Inetpub\wwwroot\cgi-bin\Default.asp
QUERY_STRING = 
REMOTE_ADDR = 150.1.8.252
REMOTE_HOST = 150.1.8.252
REQUEST_METHOD = GET
SCRIPT_NAME = /cgi-bin/Default.asp
SERVER_NAME = nous
SERVER_SOFTWARE = Microsoft-IIS/4.0
http://www.ksa-123.com
http://www.ksa-2000.com
http://www.chat-kuwait.com
http://www.vip-kuwait.com
http://www.chat-3rb.com
http://www.vip-3rb.com
http://www.3rb-chat.com
http://www.vipgulf.com
http://www.chat-gulf.com
http://www.vip-gulf.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



© 1999-2004 Synop Pty Ltd