That is about the default directory in which Apache Web Server places your projects. Webapps, on the other hand, is about the same but considering Tomcat, a web container. Remind Tomcat and Apache (Web Server) aren´t the same stuff although they can work together.
Icaro Dourado wrote:That is about the default directory in which Apache Web Server places your projects. Webapps, on the other hand, is about the same but considering Tomcat, a web container. Remind Tomcat and Apache (Web Server) aren´t the same stuff although they can work together.
Thanks for your answer, Icaro. So if the Apache (webserver) and Tomcat (web container) are deployed together as they often are, which of the following two locations would the application reside in?
The apache web server is not able to execute servlets.
Therefore if in your understanding, an application is equal to servlets, than apache web server is not the place for your application.
If you consider an application to be a composition of static and dynamic content, than (ideally):
- apache web server should serve static content (htdocs/),
- tomcat web container should serve dynamic content (webapps/).
For small applications it is commonly used to let the tomcat web container serve both - dynamic and static content. Then your whole application is in webapps/ directory in tomcat root folder.
Most importantly - performance. Apache web server is faster when it comes to just serving static data. This cooperation (Apache Web Server + Apache Tomcat) also gives you the ability to do the load balancing by removing those "dumb" static resources requests service from the more important dynamic content (business functionality).
What's important - it doesn't mean you cannot serve dynamic content using Apache web server. You just can't serve dynamic Java content.
But still, one can write full application executed in Apache web server written, let's say in PHP (with appropriate mod installed). CGI will also do the work.
The point is that Tomcat gives you the web container (servlet container, JSP container, ...) which allows you to write web applications in Java programming language (btw: which conforms to JEE specification).
Tomcat can also serve static content, but it was designed mainly to serve dynamic Java content.
Joined: Oct 24, 2010
Thanks Pedro. Is there anyway we can figure out the location of servlet container, JSP container, ... by looking at web container in Tomcat.
I don't see any reason why you should do that, even if you could :-)
Particular container is just an implementation of JEE specification. If you are a developer USING this implementation, you should be interested only in its interface, not the implementation itself - that's the main idea of this specification.
You just put your application in the tomcat_root/webapps directory and the rest of the job is left for the tomcat. He executes your servlets, he translates the JSPs to the servlets, he manages the lifecycle, sessions, application context, etc.
Joined: Oct 24, 2010
Yes Pedro. I agree with you. I just wanted to know so that I get good feel and feel comfortable when I see the directories/files.
Saibabaa, the best source of what particular directory in Tomcat does is the official documentation or a book about Tomcat, like "Pro Apache 6" by M. Moodie, Apress.
From first things that comes in my mind, you can check your "work" directory which should contain servlets Java code translated from JSP by Jasper (engine for translating JSP pages into plain java servlets).