• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is server's document root????

 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In the Servlet API for ServletContext.getContext(String uri)----->
This method allows servlets to gain access to the context for various parts of the server, and as needed obtain RequestDispatcher objects from the context. The given path must be begin with "/", is interpreted relative to the server's document root and is matched against the context roots of other web applications hosted on this container

Can anyone explain me what is the meaning of server's document root??




Again, in the Tomcat's server.xml file, I've seen an entry like------>
<Context path="/Testing" reloadable="true" docBase="C:\Tomcat 5.0\webapps\Testing" workDir="C:\Tomcat 5.0\webapps\Testing" />
as I've a project(or web application) under the webapps folder of the Tomcat. I'm unable to understand the difference b/w Context path, docBase & workDir in the entry in server.xml

Plz clarify my doubts, I'd be really grateful.

Regards,
Amit

[ May 22, 2006: Message edited by: Amit Das ]
[ May 22, 2006: Message edited by: Amit Das ]
 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone reply for this simple quetion???
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing the "server document root" is actually referring to the "domain document root" - i.e. the path underneath the domain name at which the application is deployed. For example, a forum application might be deployed to www.domain.ext/forum/ and all its components are then accessible under that root... in this case the context root is /forum.

This terminology is a bit misleading - the actual document root on a Unix server is just /; in Tomcat, the document root is the docBase (see below); on a Windows machine it could be just about anything I suppose (for example C:\ or D:\, or more recently they seem to prefer "Desktop" on desktop Windows editions).

As far as Tomcat goes, the context root is the path to the application underneath the domain (configured as a virtual host, or <host> in server.xml), and this is the same context root returned from ServletContext.getContext(String).

The docBase is the path on the server under which all files for the application are held. Simply take any resource in your application in your filesyste, replace the docBase path with the context root, and you've got the path as seen by people visiting your domain (not completely true for dynamic components like servlets or for resources in /WEB-INF, but its close).

The workDir is the working directory - it's a temporary path designed to be used during the life of the application but without the need to persist those files after shut-down. For example, automatically generated servlets (from JSPs) are saved here. This is somewhat analogous to using the system property java.io.tmpdir and the createTempFile method in java.io.File.

However, you don't need to learn anything about server.xml for the exam - only the context (root) path needs to be known.
 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Charles
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic