We are trying to enable our Tomcat 6 server to run a CGI script in Perl. We went to tomcat6/conf/web.xml and uncommented the portions of XML that defined the CGI servlet, setting cgiPathPrefix to WEB-INF/cgi, and its mapping, setting the URL pattern to cgi/* . We created a WEB-INF/cgi directory and unpacked scripts into it. We downloaded servlets-cgi.renametojar from a Tomcat 5 distribution, placed it in tomcat6/lib/, and renamed it to servlets-cgi.jar. (There was no such file in the Tomcat 6 distribution.) We restarted Tomcat after each step and pointed our browser to the CGI script URL. The browser loads the script as text, but does not run it. The text tells us that we haven't configured Tomcat properly to run CGI scripts. The first line in the CGI script is
and we have confirmed that we have a working Perl installation at that location.
If you are running Tomcat6 then you do not need to add this cgi jar. That's only if you are using Tomcat 5.5 or below.
I don't think your problem is in the perl installation. I think it's how you are configuring the CGI.
I've gotten CGI to work in Tomcat6. However, in my case I am turning on the CGI within my application web.xml, rather than in the global web.xml.
This is my directory structure.
Then I created a perlexample.xml in my $CATALINA_BASE/conf/Catalina/localhost directory.
Then it works. I am thinking you are missing this application xml in your $CATALINA_BASE/conf/Catalina/localhost directory.
Joined: Aug 31, 2009
And this is my very simple PERL script.
Joined: Oct 17, 2010
if you are getting java.security.xception make sure to do the following
In the directory $CATALINA_HOME\conf\ set the root element as <Context privileged="true"> in the context.xml file
i.e add privileged="true" attribute in the <Context > root element