Java Web Server 2.0  

Running Existing CGI Scripts


Contents / Index / Glossary / AdminTool Help

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 Java Web Server(TM) -- 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 an example in re-writing your CGI scripts as servlets, see Processing Forms with Servlets.

CGI Servlet Parameters

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

Specify initial arguments when you configure the servlet in the Administration Tool. To do this, set the initArg property in the Properties panel of the Admintool's Servlet Configuration screen. The arguments will be passed to CgiServlet when the servlet is loaded and initialized. The Administration Tool: Configuring Servlets online document describes the screen where this configuration is performed

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-cgi.pl, you would simply enter the following into the locator field of your browser:
http://host/cgi-bin/test-cgi.pl?arg1, arg2


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