• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Perl/Cgi in Tomcat 5.5

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vit bl",
Please check your private messages.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.




 
Pulkit Malhotra
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just forget to mention i'm working on window XP. All jsp files are working properly.

Thanks in advance.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!