Sorry if my post is about Python, but not a lot of Python ppl run on
Tomcat and I also develop in
Java and was hoping perhaps some Java/Tomcat ppl could help me out.
I have done the following per the instructions from the Tomcat 6 CGI How-To (
http://tomcat.apache.org/tomcat-6.0-doc/cgi-howto.html):
1) Added these lines in my web app's web.xml file:
<
servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<init-param>
<param-name>executable</param-name>
<param-value>d:\_python26\python.exe</param-value> <----- This is where I have Python installed
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
2) In my web app's context.xml file I added privileged="true"
3) I saved this Python script (hello.py) below in "d:\_tomcat\webapps\python\WEB-INF\cgi" folder:
from os import *
from cgi import *
print "Content-type: text/html\n\n"
print "<B>Hello World!</B>"
4) Then I pointed my browser to "http://localhost/python/cgi-bin/hello.py" But all I get is a blank HTML page, no error messages at all. To see if it is because it is not finding my executable correctly, I removed the executable parameter, then I get a Perl not found error. I also used forward slashes and back slashes and I still get a blank page.
Let me preface this by saying my overall Tomcat installation is working correctly, my Java web apps work correctly. But for some reason, Tomcat is not parsing the .py file correctly or not at all. I also added the location of the python.exe to my OS's path variable (I'm on WinXP machine). But I still get the blank HTML page. Offline, my normal Python scripts run correctly also in interactive/command prompt mode.
I also tried adding "#!d:/_python26/python" or ""#!d:/_python26/python.exe" at the top of my Python script, but I still get a blank page (also tried back slashes too).
Any help on this would be greatly apprciated!
Regards,
Daniel