The Tomcat 4 Servlet/JSP Container - CGI How To

Links

- Docs Home

Getting Started

- Introduction
- READ ME
- Install and Run
- Building from Source

Configuration

- Reference

Administrators

- CGI HOW-TO
- Class Loader HOW-TO
- Connectors List
- HTML Manager App HOW-TO
- JK Documentation
- JNDI DataSource HOW-TO
- JNDI Resources HOW-TO
- JSP Engine Config HOW-TO
- Manager App HOW-TO
- MBean Descriptor HOW-TO
- Proxy Support HOW-TO
- Realm HOW-TO
- Security Mgr. HOW-TO
- SSI Config HOW-TO
- SSL Config HOW-TO

Application Developers

- App Developer Guide
- Servlet/JSP Javadocs

Catalina Developers

- Functional Specs.
- Javadocs

Jasper Developers

- Javadocs

# The Tomcat 4 Servlet/JSP Container

## CGI How To

print-friendly
version

Introduction

> The CGI (Common Gateway Interface) defines a way for a web server to interact with external content-generating programs, which are often referred to as CGI programs or CGI scripts.

> Within Tomcat CGI support can be added when using Tomcat as your HTTP server and you require CGI support. Typically this is done during development when you don't want to run a web server like Apache.

> CGI support is implemented using the servlet class `org.apache.catalina.servlets.CGIServlet`. Traditionally, this servlet is mapped to the URL pattern "/cgi-bin/*".

> By default CGI support is disabled in Tomcat.

Installation

> CAUTION - CGI scripts are used to execute programs external to the Tomcat JVM. If you are using the Java SecurityManager this will bypass your security policy configuration in `catalina.policy.`

> Rename `$CATALINA_BASE/server/lib/servlets-cgi.renametojar` to `$CATALINA_BASE/server/lib/servlets-cgi.jar`.

> Remove the XML comments from around the CGI servlet and servlet-mapping configuration in `$CATALINA_BASE/conf/web.xml`.

Configuration

> There are several servlet init parameters which can be used to configure the behaviour of the CGI servlet.

> - cgiPathPrefix - The CGI search path will start at the web application root directory + File.separator + this prefix. The default cgiPathPrefix is `/WEB-INF/cgi`
> - debug - Debugging detail level for messages logged by this servlet. Default 0.
> - executable - The of the executable to be used to run the script. Default is `perl`.
> - parameterEncoding - Name of the parameter encoding to be used with the GCI servlet. Default is `System.getProperty("file.encoding","UTF-8")`.
> - passShellEnvironment - Should the shell environment variables (if any) be passed to the CGI script? Default is `false`.

Copyright © 1999-2002, Apache Software Foundation