• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How useful is Apache when it is integrated with Tomcat?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bosch Vaklor
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
The moustache of a titan! The ad of a flea:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic