aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ - directory name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ - directory name "htdocs" instead of "webapps"" Watch "HFSJ - directory name "htdocs" instead of "webapps"" New topic
Author

HFSJ - directory name "htdocs" instead of "webapps"

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

HFSJ book mentions on page 22, "An Apache server will assume that "htdocs" is the directory that is the root for all of the server's web applications."

Is this a typo? Did the authors mean "webapps" instead of "htdocs"? I couldn't find anything on the online Errata.

Thanks,
Nidhi


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Icaro Dourado
Greenhorn

Joined: Dec 30, 2007
Posts: 9
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.


SCJP 5, SCWCD 5
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

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?

1. Apache_root_directory/htdocs
2. Tomcat_root_directory/webapps


Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

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.


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Thanks Pedro. That makes it clear for me.
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
So, What is the use of apache web server that can server only static content when compared to apache Tomcat that can serve both static and dynamic content?
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

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.
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Thanks Pedro. Is there anyway we can figure out the location of servlet container, JSP container, ... by looking at web container in Tomcat.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

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.
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
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.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

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).

Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFSJ - directory name "htdocs" instead of "webapps"
 
Similar Threads
Compiling JSPs into directories
unable to view index.html pahe in webapps folder
Is it necessary to copy my sites from htdocs to WEBAPPS in Tomcat7
Context hell
Servlet is not displaying from browser