Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to execute CGI Programs in Tomcat Server

843841Apr 26 2004 — edited Aug 21 2007
Hi,
I am working on executing Perl Scrtipts(or CGI programs) in Tomcat Server.
I have downloaded ActivePerl 5.8.0 6.0.3 build.I have modified some .jar files in tomcat\server\lib.
I have changed conf\web.xml to access the CGIServlet.class that is in servlets-cgi.jar.

My example.cgi is
-----------------------


#!c:\Perl\bin\perl.exe
print
"Content-type: text/plain\n\n";

foreach $var (
sort keys %ENV) {
print
"$var=\"$ENV{$var}\"\n";
}

@values = split(
/&/,$ENV{'QUERY_STRING'});
foreach $i (@values) {
($varname, $mydata) = split(
/=/,$i);
print "$varname = $mydata\n";
}


and my test.html is
-------------------------

<HTML>
<HEAD>
<TITLE>Environment Variables using GET</TITLE>
</HEAD>

<BODY>
<FORM ACTION="cgi-bin/example.cgi" METHOD="POST">
Press submit for a list of environment variables. <BR>
First Name: <input type="text" name="fname" size=30><p>
Last Name: <input type="text" name="lname" size=30><p>
<input type="submit">
</FORM>
</BODY>
</HTML>

here I have changed url mapping in web.xml to cgi-bin.
The test.html produces two text fields first and last name on submit:
it accesses:http://localhost:8080/smalltownpapers/cgi-bin/example.cgi?fname=Tim&lname=Eden
this should print some environmental variables but it is producing an empty page.
Tomcat is not showing any errors or Tomcat is not at all listening.

Can any one help me to solve this and how to execute Perl scripts in Tomcat server
Thanks,
Regards
Murthy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 18 2007
Added on Apr 26 2004
3 comments
212 views