title: Running CGI on Jetty
body: <p>I'm starting Jetty from inside the Java program itself. I'm simply trying to get it to point at a cgi-folder that I've placed underneath the package directory (/src/package/cgi-bin)</p>
  
  <p>The problem is that every time I start up the server, it complains "no CGI bin!". Where is the correct location to put your cgi-bin and point at it? This is what I have:</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
      // The core Jetty server running on 8080
      Server server = new org.eclipse.jetty.server.Server(8080);
  
      // Setup CGI routing
      ServletContextHandler context2 = new ServletContextHandler(ServletContextHandler.SESSIONS);
      context2.setContextPath("/");
      context2.setInitParameter("commandPrefix", "perl");
  
      // Where does this point to? 
      context2.setInitParameter("cgibinResourceBase", "cgi-bin");
      server.setHandler(context2);
  
      // Add the CGI Servlet
      context2.addServlet(new ServletHolder(new Cgi()), "/cgi");
  
      server.start();
      server.join();
  }
  </code></pre>
  
  <p><strong>See <a href="https://stackoverflow.com/questions/9216650/jetty-setinitparameter-is-not-initializing-any-parameter">Jetty setInitParameter is NOT initializing any parameter</a> for the answer to this question.</strong></p>