Hi,

I'm new to Perl, I installed ActivePerl in my machine and it is running properly. But when I'm trying to open a CGI using Tomcat I'm getting HTTP Status 404 error.

I also did the following

Altered Tomcat's C:\apache-tomcat-6.0.10\conf\web.xml file

a) There's a CGIServlet that's commented out; so I removed the comments for lines
<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>

b) Associate URLs cgi-bin with the CGI Servlet.
Code:
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
Then this is the directory I created C:\apache-tomcat-6.0.10\webapps\ROOT\WEB-INF\cgi and in the cgi folder I have a file named hello.cgi

hello.cgi contains the following code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "<html><head>\n";
print "<title>Hello, world!</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
print "<h1>Hello, world!</h1>\n";
print "</body></html>\n";

I tried all these urls
http://localhost/hello.cgi in the browser
http://localhost/cgi/hello.cgi
http://localhost/cgi-bin/hello.cgi
I got HTTP Status 404 - /hello.cgi. The requested resource (/hello.cgi) is not available.

Can anyone please tell me what I'm doing wrong
Thank you,
raj

First you need to go through this thread, in my opinion. As Kevin was replying to your earlier post it is nothing to do with Perl as such, only thing you need to place the scripts in right place so that you can call those scripts in browser.

The error status 404(requested resource not available)the error is exactly what is going to pop up because the resource you are requesting cannot be found by server.

katharnakh.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.