Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


CGI Environment Variables

May 8, 2000

CGI Environment Variables

In addition to the SSI Environment Variables, the CGI Variable set is also available.

SERVER_SOFTWARE
The name and version of the server software

<!--#echo var="SERVER_SOFTWARE" -->

SERVER_NAME
The server's hostname, DNS alias, or IP address

<!--#echo var="SERVER_NAME" -->

GATEWAY_INTERFACE
The revision of the CGI specification to which this server complies

<!--#echo var="GATEWAY_INTERFACE" -->

SERVER_PROTOCOL
The name and revision of the information protocol this request came in with, ie. HTTP/1.0

<!--#echo var="SERVER_PROTOCOL" -->

SERVER_PORT
The port on which the server is answering

<!--#echo var="SERVER_PORT" --> 

REQUEST_METHOD
The method by which the document was requested. This is GET, HEAD, POST for HTTP.

<!--#echo var="REQUEST_METHOD" -->

PATH_INFO
Scripts can be accessed by their virtual pathname, (relative to the base directory), followed by extra information, as given by the client, at the end of this path.

<!--#echo var="PATH_INFO" --> 

PATH_TRANSLATED
The server translates the PATH_INFO from virtual-to-physical location.

<!--#echo var="PATH_TRANSLATED" --> 

SCRIPT_NAME
This is the virtual path to the script being executed.

<!--#echo var="SCRIPT_NAME" --> 

QUERY_STRING
This is the text at the end of a URL that has a ? in it, e.g. http://somedomain.com/directory/file.html?querystringtext

<!--#echo var="QUERY_STRING" --> 

Great, but that's just a URL. How do I use it you ask. Here's a little example, not much good for anything, but kinda cool if you've never seen it before.

Add a link to color.html on one page, using the syntax below.

<a href="color.html?red">color</A>

Create color.html putting the following include into it. That's right, the directive goes into the page being linked to rather than the page being linked from.

<!--#set var="color" value="$QUERY_STRING" -->

<font size="+2" face="Arial,Helvetica" color=
"<!--#echo var="color" -->">
<!--#echo var="QUERY_STRING" --></font>

See the example

If you were to go directly to color.html without clicking on the link you would see nothing at all. The content of the page, in this case one word only is the string after the ? in the URL. If the URL had been <A HREF="color.html?green"> you would see the word green instead of red.

Printing Environment Variables with echo
Server Side Includes
CGI Environment Variables cont.


Up to => Home / Authoring / SSI / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers