aspose file tools*
The moose likes Tomcat and the fly likes How useful is Apache when it is integrated with Tomcat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How useful is Apache when it is integrated with Tomcat?" Watch "How useful is Apache when it is integrated with Tomcat?" New topic
Author

How useful is Apache when it is integrated with Tomcat?

Bosch Vaklor
Greenhorn

Joined: Jul 11, 2013
Posts: 6
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?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

Welcome to the JavaRanch, Bosch!

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bosch Vaklor
Greenhorn

Joined: Jul 11, 2013
Posts: 6
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?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

Apache+Tomcat is alive, well, and thriving. In fact, I just set up another pairing late last week.

To clarify a bit on Ulf's last comment, the proxying (connector) components permit some URL rewriting, especially when used with Apache virtual hosts. But mod_rewrite allows more extensive changes.

The mod_rewrite facility is no replacement for Apache-tomcat proxying, but it is excellent for getting a lot of grungy stuff out of the external URLs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How useful is Apache when it is integrated with Tomcat?