JavaServer

Running Existing CGI Scripts Using the CGI Servlet


Java Web Server Documentation / Developer Docs / Administrator Docs / Index / Features

There's no need to throw your existing CGI scripts away. Any CGI script you can run on other web servers, such as Apache, you can run on the JavaTM Web ServerTM -- including scripts written in C, C++, and Perl. This document tells you how.

Note: While it's true you can run your existing CGI scripts on the Java Web Server, you can gain improved performance and code simplicity by using servlets instead. For help in re-writing your CGI scripts as servlets, see Replacing CGI Scripts with Servlets.

CGI Servlet Parameters

The CGI servlet, CgiServlet, implements the HTTP/1.1 interface. It takes the following initial arguments:

The arguments can be passed to CgiServlet at the load/initialization time by specifying the arguments as part of the server configuration.

Descriptions and default settings for these arguments are given below. On UNIX platforms, the default setup should work with no change. On Windows 95 and Windows NT platforms, you will likely have to set perlexe.

bindir

This argument is used to tell the servlet the location of your CGI scripts. The default value is server_root/cgi-bin.

The value is relative to server_root. If you wanted to change the location to server_root/gdb-bin, for example, you would enter:

bindir=gdb-bin

dns

This argument controls whether DNS reverse lookup is performed. Note that setting this argument to true can impact performance dramatically. The default value is false.

perlexe

This argument specifies the full path to your Perl executable. You don't need to set perlexe unless you can't run self-executing scripts (for instance, when running on Windows 95 or Windows NT). Note that the path you set is relative to the server-root directory. The default is not set.
perlexe=c:/Perl/bin/Perl.exe

cgiexe

This argument specifies the native CGI launch program. The default is server-root/bin/cgilaunch. The Java Web Server comes with the source code for cgilaunch to allow you to add your own key environment settings.

path

When you start up the Java Web Server, it passes the PATH environment variable to the System Properties path variable (SYSTEM_PATH_PROP). If you want to override that behavior, use this argument.

Running CGI scripts on the Java Web Server

The CGIServlet has been aliased to the string /cgi-bin. This means invoking the servlet looks the same as invoking CGI directly. For example, to run the CGI script test, you would simply enter the following into the locator field of your browser:
http://host/cgi-bin/test?arg1, arg2


Top
java-server-feedback@java.sun.com
Sun Microsystems
Copyright© 1997 Sun Microsystems, Inc.
All Rights Reserved.