This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
If you are going to serve only static(such as HTML) pages then Apache webserver would suffice but if the pages being (dynamically) served are in JSP/Servlet then you need a container that can interpret them, for which we use Tomcat.Similarly, if you will be using PHP then you need to add its support in Webserver. Webserver is used to just respond to the requests with feature such as load balancing, whereas containers( such as Tomcat) are used to manage the lifecycle of the pages generated using JSP and servlet.. If you need more info on the container specific responsibilty then you can check out either the JSP or Servlet specification.
Joined: Oct 27, 2005
I forgot to add that you can't use Tomcat as a web server . You can check for more info at Apache-Tomcat
Originally posted by Sunny Kumar: I forgot to add that you can't use Tomcat as a web server .
As Ben pointed out, this is completely incorrect. Modern versions of Tomcat can not only be used as a stand-alone web server, it is generally considered a very good one.
Joined: Oct 27, 2005
Originally posted by Ben Souther: You certainly can use Tomcat as a standalone webserver.
Ya..agree with that. I should have emphasized more on the word web-server because I think there has to be some features that only a web server is able to provide or atleast cnsidered best for. [ December 30, 2005: Message edited by: Sunny Kumar ]
Originally posted by Hemant Agarwal: My question is If we can use Tomcat as a standalone server than why we will ever need to combine apache + tomcat as a server
It used to be that Tomcat/Java was so much slower than Apache HTTPD when it came to serving static files that you had to combine them to get a production ready application. This is no longer the case. Most often, the gains you get by combining the two (if any) are not worth the hassle of administering both + the connector.
There are other reasons though. If your app has components written in other technologies than Java such as PHP or PERL, you may prefer to use HTTPD to handle those things. If you have huge amounts of static data and very little Java driven dynamic stuff, it may be more efficient to let HTTPD handle the static data. Some people combine the two in order to bind to a port below 1024 on a unix box or to share an SSL certificate between different apps. HTTPD can also be used as a load balancer for several instances of Tomcat.
In short, unless you have a compelling reason to do so, I wouldn't bother connecting the two. I would stick to Tomcat as a standalone until there is solid proof (in the form of a load test) that life would be better with an HTTPD front end.