permaculture playing cards*
The moose likes Tomcat and the fly likes Perl/Cgi in Tomcat 5.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Perl/Cgi in Tomcat 5.5" Watch "Perl/Cgi in Tomcat 5.5" New topic
Author

Perl/Cgi in Tomcat 5.5

viktor boulg
Greenhorn

Joined: Jan 20, 2008
Posts: 7
I have a problem with running my CGI script on my local host.

What am I possibly missing?

I did:

1) I installed Tomcat on my PC.
2) In file
/cygdrive/c/Program Files/Apache Software Foundation/Tomcat 5.5/conf/web.xml
* I uncommented
<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>6</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>

* in <!-- The mapping for the CGI Gateway servlet -->
I did:
<!-->
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*.cgi</url-pattern>
</servlet-mapping>
<-->
3) in
c/Program Files/Apache Software Foundation/Tomcat 5.5/server/lib
mv servlets-cgi.renametojar servlets-cgi.jar

4) in c/Program Files/Apache Software Foundation/Tomcat 5.5/server/webapps/host-manager/WEB-INF/cgi
I created file test.cgi and geve it chmod 777 permission

5) restarted tomcat
6) link
http://localhost:8080/cgi-bin/test.cgi
returns: The requested resource (/cgi-bin/test.cgi) is not available.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"vit bl",
Please check your private messages.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You put your script into the host-manager application.
If you want to keep it there, you'll need to adjust your URL to point to that app.
viktor boulg
Greenhorn

Joined: Jan 20, 2008
Posts: 7
Originally posted by Ben Souther:
You put your script into the host-manager application.
If you want to keep it there, you'll need to adjust your URL to point to that app.


Could you tell me how. I tried several approaches but failed.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Before I can do anything, you'll need to check your private messages and take care of the matter mentioned in there.
viktor boulg
Greenhorn

Joined: Jan 20, 2008
Posts: 7
Originally posted by Ben Souther:
Before I can do anything, you'll need to check your private messages and take care of the matter mentioned in there.


Just did it, so, if possible could you help.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Servlet containers support the concept of web applications.

In Tomcat, each is located inside the tomcat/webapps directory.
Each application (or context) can be accessed by adding the contextPath to the end of the domain.

Example:
http://localhost:8080/myContextPath

Inside the webapps directory is a special folder named ROOT.
This is the root web application for the container.
If you just want to try running one JSP, HTML page, or in your case, a CGI script, put it inside the ROOT directory.

Example:
If you put a page named hello.html in:
tomcat/webapps/ROOT/
You could access it with the following URL:
http://localhost:8080/hello.html

I haven't done much with the CGI servlet that ships with Tomcat but this should be enough to enable you to reach it with a browser.
viktor boulg
Greenhorn

Joined: Jan 20, 2008
Posts: 7
Originally posted by Ben Souther:
Servlet containers support the concept of web applications.

In Tomcat, each is located inside the tomcat/webapps directory.
Each application (or context) can be accessed by adding the contextPath to the end of the domain.

Example:
myContextPath[/b]]http://localhost:8080/myContextPath

Inside the webapps directory is a special folder named ROOT.
This is the root web application for the container.
If you just want to try running one JSP, HTML page, or in your case, a CGI script, put it inside the ROOT directory.

Example:
If you put a page named hello.html in:
tomcat/webapps/ROOT/
You could access it with the following URL:
http://localhost:8080/hello.html

I haven't done much with the CGI servlet that ships with Tomcat but this should be enough to enable you to reach it with a browser.


Thank you very much for your help. So far I used our unix servers whith Tomcat and now decided to install it myself on my computer.

http://localhost:8080/hello.html (located in ROOT) works fine which most probably means that tomcat, java and env variables are set correctly, right?

However http://localhost:8080/cgi-bin/ is not seen, although it seems that I correctly modified
c/Program Files/Apache Software Foundation/Tomcat 5.5/conf/web.xml

BTW am I right that I start and stop Tomcat with:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin\tomcat5w.exe
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by viktor boulg:
...
BTW am I right that I start and stop Tomcat with:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin\tomcat5w.exe


If you've installed with the '.exe' version of the installer, you should use the start menu items or the Window's Services panel.
Otherwise, you should use tomcat/bin/startup.bat from the command line.

I've never worked with the CGI Servlet so I'm not sure what else needs to be done to get it going.

Out of curiosity, why are you using Tomcat for a Perl application?
That's usually done with the Apache Web Server.
Pulkit Malhotra
Ranch Hand

Joined: Apr 15, 2005
Posts: 30
I'm also facing the similar problem.

I have uncommented the sections from web.xml. and rename the jar also.
When i'm running the at following path.
http://127.0.0.1:8080/work/cgi/Hello.cgi

It is displaying what is written in the script.
echo "Hello World!"

Please let me know what i'm missing. Seems as system is not recognizing it as cgi script.





Regards,<br />Pul_Mal
Pulkit Malhotra
Ranch Hand

Joined: Apr 15, 2005
Posts: 30
Just forget to mention i'm working on window XP. All jsp files are working properly.

Thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Perl/Cgi in Tomcat 5.5
 
Similar Threads
Problem running simple Servlet on Tomcat
Error in FilterStart Struts 2 web app
new to struts
Servlet not showing up in Browser
Deploying the application