Let Tomcat start EXE in CGI Path
How to activate CGI in Tomcat
[a] uncomment in conf/web.xml the bloc <servlet-name>cgi</servlet-name>
[b] uncomment the bloc of servlet mapping for cgi (begins with <servlet-mapping>)
[Before Tomcat 6.0]
[c] in /server/lib rename the file servlets-cgi.renametojar with servlets-cgi.jar
TEST
Create the folders "webappsmycgiWEB-INFcgi" and create there a new file called time.cgi with the following code:
#!/usr/bin/perl
print "Content-type: text/htmlnn";
$now = localtime();
print "<h1>It is $now</h1>";
Start Tomcat. The call http://localhost:8080/mycgi/cgi-bin/time.cgi should give something like It is Thu Nov 5 13:54:18 2009
EXE
By default, Tomcat is configured to consider the files with the .cgi extension as Perl scripts. If you want to start an exe file, the solution is to configure the file conf/web.xml with the following parameter at the place of your CGI configuration
<init-param>
<param-name>executable</param-name>
<param-value></param-value>
</init-param>
Warning ! That gives yet the rights an Tomcat to start any type of file. So, be careful and specify the language (Ruby, Objective-C for example) in the param-value.
[a] uncomment in conf/web.xml the bloc <servlet-name>cgi</servlet-name>
[b] uncomment the bloc of servlet mapping for cgi (begins with <servlet-mapping>)
[Before Tomcat 6.0]
[c] in /server/lib rename the file servlets-cgi.renametojar with servlets-cgi.jar
TEST
Create the folders "webappsmycgiWEB-INFcgi" and create there a new file called time.cgi with the following code:
#!/usr/bin/perl
print "Content-type: text/htmlnn";
$now = localtime();
print "<h1>It is $now</h1>";
Start Tomcat. The call http://localhost:8080/mycgi/cgi-bin/time.cgi should give something like It is Thu Nov 5 13:54:18 2009
EXE
By default, Tomcat is configured to consider the files with the .cgi extension as Perl scripts. If you want to start an exe file, the solution is to configure the file conf/web.xml with the following parameter at the place of your CGI configuration
<init-param>
<param-name>executable</param-name>
<param-value></param-value>
</init-param>
Warning ! That gives yet the rights an Tomcat to start any type of file. So, be careful and specify the language (Ruby, Objective-C for example) in the param-value.
Retour aux articles de la catégorie Computer sciences -