This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
1. It is said that Apache is basically a HTTP web server which handles mostly static requests and Tomcat handles servlets/jsps. So, when you want to offload static requests to Apache, then it is better to use Apache and Tomcat together right?
2. To have both Tomcat and Apache, we need mod_jk plugin which has attributes : forwardAll and noRoot. In http://tomcat.apache.org/tomcat-3.3-doc/mod_jk-howto.html it is said that forwardAll by default is true which means that it forwards all the requests to Tomcat. When it says all requests, does Apache still handle static requests? Is there any other use of Apache when Tomcat handles all the requests?
3. And, noRoot attribute says if it is true, the root context is not mapped to Tomcat. What does this imply? Does this mean that all the requests will go through the apache?
It is said that Apache is basically a HTTP web server which handles mostly static requests and Tomcat handles servlets/jsps. So, when you want to offload static requests to Apache, then it is better to use Apache and Tomcat together right?
Not sure where you read that, but it is extremely common for Apache to handle dynamic sites (for example, using the mod_php module). Furthermore, while it was true at some point that Tomcat was not well suited for handling static content, that was about 10 years ago (in the days of Tomcat 3.x) - its performance has improved dramatically, up to the point where there's no reason to avoid Tomcat for static content.
I can't speak to the other questions, except to advise to consult the documentation of current Tomcat versions instead of Tomcat 3, which has been obsolete for many years.
As Ulf has said, the idea that you should use Apache to serve static content for J2EE webapps is an outdated old wives tale.
However, Apache is VERY useful when integrated with Tomcat. It provides "one-stop shopping" for a mixed bag of J2EE and non-J2EE (e.g., python, php, cgi) webapps. It avoids the issue where Tomcat cannot own TCP/IP ports 80 and 443 without running under (dangerous) root permissions. It can act as a load balancer for multiple Tomcat instances. It can proxy for a Tomcat that's on a machine not directly attached to the open Internet.
mod_jk, however, is not the only way to link Apache and Tomcat. I use mod_proxy. There's also a third mechanism, I think, though I forget what it is.
You are looking at documentation that is so old it's probably mixed with dinosaur bones. The current production release of Tomcat is Tomcat7 and the current Apache httpd server release is 2.4.
An IDE is no substitute for an Intelligent Developer.
Joined: Jul 11, 2013
Thanks guys! Haha, I liked that line with the dinosaur bones. That was just a reference that I had given for mod_jk. Not sure if there are any changes on mod_jk (incl its attributes). Also, Apache and Tomcat combination is still used right?
For a normal web application project, what would you suggest? Now, since Tomcat is much capable of handling many things, is Tomcat just sufficient as a web server/web container?
Joined: Mar 22, 2005
is Tomcat just sufficient as a web server/web container?
It is sufficient for many web apps, but as Tim points out, fronting it with an Apache still has many benefits. To which I would add one more: the Apache mod_rewrite module, which allows you to alter or adapt the URL space without having to change the web app. You'll have to decide whether any of these are important in your case.