<?xml version="1.0"?>
<!DOCTYPE document [
  <!ENTITY project SYSTEM "project.xml">
]>
<document url="cgi-howto.html">

    &project;

    <properties>
        <author email="glenn@apache.org">Glenn L. Nielsen</author>
        <title>CGI How To</title>
    </properties>

<body>

<section name="Introduction">

<p>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.
</p>

<p>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.</p>

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

<p>By default CGI support is disabled in Tomcat.</p>
</section>

<section name="Installation">

<p><strong>CAUTION</strong> - 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 <code>catalina.policy.</code></p>

<p>Rename <code>$CATALINA_BASE/server/lib/servlets-cgi.renametojar</code>
to <code>$CATALINA_BASE/server/lib/servlets-cgi.jar</code>.</p>

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

<section name="Configuration">

<p>There are several servlet init parameters which can be used to
configure the behaviour of the CGI servlet.
<ul>
<li><strong>cgiPathPrefix</strong> - The CGI search path will start at
the web application root directory + File.separator + this prefix.
The default cgiPathPrefix is <code>/WEB-INF/cgi</code></li>
<li><strong>clientInputTimeout</strong> - The time (in milliseconds) to
wait for input from the browser before assuming that there is none.
Default is <code>100</code> seconds.</li>
<li><strong>debug</strong> - Debugging detail level for messages logged
by this servlet. Default 0.</li>
</ul>
</p>

</section>

</body>

</document>
