Felipe,

As noted in the web.xml comments, in order to make cgi-servlet working, you
need to package cgi scripts with your web application (e.g. yourapp.war):

"Common Gateway Includes (CGI) processing servlet, which supports execution
of external applications that conform to the CGI spec requirements.
 Typically, this servlet is mapped to the URL pattern "/cgi-bin/*", which
means that any CGI applications that are executed must be present within
the web application..."


So, if you deployed your webapp as
/home/luis/tomcat/apache-tomcat-8.0.0-RC5/webapps/YOURAPP


You will need the following files in your YOURAPP folder:

WEB-INF/cgi/project.cgi
WEB-INF/cgi/subparseform.lib
ProjectAnalysis.html

Your ProjectAnalysis.html will have the following form action URL, e.g.

<form action="http://localhost:8080/YOURAPP/cgi-bin/project.cgi";
method="post">
...
</form>


Make sure that both <servlet> and <servlet-mapping> are uncommented.

Read more details about CGI support here:
http://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html


Now, more important questions for you:

Why are you using Tomcat and CGI support in Tomcat? If you are not
deploying Java applications, what's the point of using Tomcat, why not just
use Apache web server (httpd)?

Why are you using subparseform.lib? It would be so much cleaner to use
JSP+Servlet code for that ... provided you have nice JSP/Java development
environment, etc...

The easiest to develop (also "terrible" way to do it) is to use just JSPs
and code all your logic, calculations etc... in JSP itself.

For example, e.g.


CATALINA_HOME/webapps/YOURAPP:

ProjectAnalysis.html
projects.jsp


----begin projects.jsp----
<html>
<body>
<h1>Results</h1>
<%

  String projcost = request.getParameter("projcost");
  String projects = request.getParameter("projects");
  String revenue = request.getParameter("revenue");

  double projcostValue = Double.parseDouble(projcost);
  double projectsValue = Double.parseDouble(projects);
  double revenueValue = Double.parseDouble(revenue);

  double average = projcostValue / projectsValue;
  double grossprofit = revenueValue - projcostValue;

%>

<p>Project Cost Last Year was $projcost dollars.</p>

<p>We completed <%= projectsValue %> projects during the year.  That works
out to an average of <%= average %> cost per project.</p>

<p>Our annual Project Revenue was <%= revenueValue %> dollars. We made a
gross profit of <%= grossprofit %> dollars</p>
</body>
</html>

----end projects.jsp----


Or something like that ... now, I don't guarantee for the correctness of
the JSP code, since I just typed it here and not actually tried it out and
tested, but you get the idea...

You really should ask yourself - why Tomcat and not some other simpler
webserver?

Good luck!
n.

Reply via email to