Felipe wrote:
Interesting, so do container-based systems such as Tomcat rely heavely on
httpd?

Not necessarily. Read on.

I've read that many people use Tomcat just for webapp deployment and
use apache to handle static pages, among other things, but is it reasonable
to use Tomcat to handle static pages, or is it solely for webapp server?

By design, Tomcat is primarily a "java servlet container", meaning that its primary design goal is to provide an environment to run java servlets efficiently.

But it is rarely so that applications would consist only of java servlets, so there exists also within Tomcat a "default servlet", which is invoked by Tomcat to serve any request which cannot clearly be assigned to any other servlet, and which consequently does serves most static content (html pages, stylesheets, images, ..).

And it just so happens that this default servlet is very efficient too, so that in the end Tomcat can perfectly be used as a "generic webserver" to serve both static content, along with the results of servlets execution.

There also exists a "cgi-bin servlet" which can run cgi-bin scripts and 
programs.
But this cgi-bin servlet is not really optimised for any particular kind of cgi-bin programs/scripts, and that is where other webservers may "beat tomcat" in terms of efficiency.

For example, if you are talking about cgi-bin scripts written in Perl or PHP : there exist special add-on modules for the Apache httpd webserver, which can optimise the running of scripts written in such languages (usually by pre-compiling them and keeping the compiled version in some cache memory)(*). Such add-on modules do not exist for tomcat, and thus if a main part of an application would consist of such scripts, it would be more efficient in an overall sense to use a front-end webserver like Apache httpd, to run these parts of the application, and then have Apache httpd "delegate" to a tomcat back-end what is destined for java servlets.

When you reflect about this, it is exactly the same in reverse : Apache httpd could also run cgi-bin scripts written in Java. It would just have to start a JVM at each invocation, to compile and run the java script. Of course, that would be very inefficient, which is why for running java servlets it is better to use tomcat (or another java servlet container).

There is nothing /in the principle/ that would prevent someone from writing a special java "perl cgi-bin servlet" for tomcat, which would duplicate the functionality of some of what the mod_perl module does for Apache httpd, and make it very efficient to run perl cgi-bin scripts under tomcat (**). It just hasn't been done yet, the main reason being probably : why do it ? (when it is easy to configure Apache httpd as a front-end to tomcat, and do it there using mod_perl).

(*) See http://perl.apache.org
(**) and similarly, one could think about a "mod_java" add-on module for Apache 
httpd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to