Jetty Java HTTP Servlet Server
Search this site with Google:
 

Can Jetty do CGI?

The Jetty distribution includes a CGI servlet org.mortbay.servlet.CGI. You configure it in your jetty.xml configuration file along these lines:

  <Call name="addContext">
    <Arg>/cgi-bin/*</Arg>
    <Set name="ResourceBase">/home/jules/www/cgi-bin</Set>
    <Set name="ServingDynamicServlets">TRUE</Set>
    <Call name="addServlet">
      <Arg>Common Gateway Interface</Arg>
      <Arg>/</Arg>
      <Arg>com.mortbay.Servlet.CGI</Arg>
     <Put name="Path">/usr/local/bin:/usr/ucb:/bin:/usr/bin</Put>
    </Call>
  </Call>

Note that you can use Put name= statements in the jetty.xml file to configure initParams for the CGI servlet, or you can use initParam statements in the web.xml descriptor.

Some useful initParams are:

Furthermore, any initParam that starts with ENV_ is interpreted by the CGI servlet as being an environment variable. The leading ENV_ is stripped and the resulting name and value are passed to the exec environment.

On Windows boxes, you may find that you need to set the initParam ENV_SystemRoot to make your script work eg:

<Put name="ENV_SystemRoot">C:/Windows</Put>


JettyFaq