Training, Open Source computer languages

This is page http://www.wellho.net/forum/Perl-Programming/Perl-CGI ... omcat.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Perl CGI scripts with SSI in Tomcat

Posted by carletto (carletto), 2 March 2006
I am trying to use SSI + CGI in Tomcat.
Installed SSI and CGI as written in the How-tos.
For CGI :
<servlet>
       <servlet-name>cgi</servlet-name>
       <servletclass>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-bin</param-value>
       </init-param>
        <load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
       <servlet-name>cgi</servlet-name>
       <url-pattern>/cgi/*</url-pattern>
</servlet-mapping>
   
Then I wrote a "index.shtml" file:
<html>
<!--#echo var="DATE_LOCAL" -->
<!--#exec cgi="ciao.cgi" -->
<!--#exec cgi="cgi/ciao.cgi" -->
<!--#echo var="DATE_LOCAL" -->
</html>
and a "ciao.cgi" file (in /webapps/ciao/ and in /webapps/ciao/WEB.INF/cgi/):
#!c:/Perl/bin/perl -wT
print "Content-type: text/html\n\n";
print "CIAO";

After writing in Explorer "http://localhost:80/ciao" I get:
Wednesday, 01-Mar-2006 17:46:50 CET #!c:/Perl/bin/perl -wT print "Content-type: text/html\n\n"; print "CIAO";
[an error occurred while processing this directive] Wednesday, 01-Mar-2006 17:46:50 CET

and in the log :
Serving buffered resource '/index.shtml'
2006-03-01 17:46:50 StandardContext[/ciao]ssi: SSIProcessor.process -- processing command: echo
2006-03-01 17:46:50 StandardContext[/ciao]ssi: SSIProcessor.process -- processing command: exec
2006-03-01 17:46:50 StandardContext[/ciao]ssi: SSIServletExternalResolver.getServletContextAndPath( ciao.cgi, true)
2006-03-01 17:46:50 StandardContext[/ciao]ssi: SSIProcessor.process -- processing command: exec
2006-03-01 17:46:50 StandardContext[/ciao]ssi: SSIServletExternalResolver.getServletContextAndPath( cgi/ciao.cgi, true)
2006-03-01 17:46:50 StandardContext[/ciao]cgi: findCGI: path=/index.shtml, J:\jakarta-tomcat-5.0.30\webapps\ciao\WEB-INF/cgi-bin
2006-03-01 17:46:50 StandardContext[/ciao]cgi: findCGI: currentLoc=J:\jakarta-tomcat-5.0.30\webapps\ciao\WEB-INF\cgi-bin
2006-03-01 17:46:50 StandardContext[/ciao]cgi: findCGI: currentLoc=J:\jakarta-tomcat-5.0.30\webapps\ciao\WEB-INF\cgi-bin
2006-03-01 17:46:50 StandardContext[/ciao]ssi: #include--Couldn't include file: cgi/ciao.cgi
java.io.IOException: Couldn't find file: /cgi/ciao.cgi
     at org.apache.catalina.ssi.SSIServletExternalResolver.getFileText(SSIServletExternalResolver.java:391)

Do you have an idea why it does not execute the script ? Where could I find a patch?
Thanks
Carlo

Posted by admin (Graham Ellis), 3 March 2006
Why are you trying to mix up SSIs and Perl code via CGIs?  If you want to use SSIs ... and execs within them ... then the program you "exec" wouldn't be to the Common Gateway Interface (CGI) standard.  Now I don't thinks that's the cause of the problem that you've reported, but I do fear that if I halp you sort this one out I would be leading you down a blind alley.

Suggestion - use JUST an SSI, or JUST a Perl based CGI program and the setup should be much easier.   If you have a substantial amount of HTML with just a little information you want to change in a Perl program, then write a Perl program that reads in a file of HTML and substitutes in it where appropriate.


Posted by admin (Graham Ellis), 3 March 2006
By the way - we have fully worked examples of using Tomcat to serve SSI pages here on our web site and to serve CGI written in Perl here on the site



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho