File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Using a different context directory than the default webapps in Tomcat 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Using a different context directory than the default webapps in Tomcat 5" Watch "Using a different context directory than the default webapps in Tomcat 5" New topic
Author

Using a different context directory than the default webapps in Tomcat 5

Andi Pema
Greenhorn

Joined: Jul 14, 2006
Posts: 3
Hi there,

I'm new to Tomcat web server. Up to now all my contexts have been deployed in the webapps directory (which is the default directory for deplyoing applications). This is tedious because my working directiory is within My Documents. So every time I finish some application I have to copy everything inside the webapps directory. I want to be able to use the My Documents as the default directory. To be more specific say I have an folder in My Documents named project1 (C:\My Documents\project1) where I have my .jsp-s and classes in their respective folders. Now I want to be able to run this application from Tomcat server i.e. http://localhost:8080/project1/some.jsp or http://localhost:8080/myproject1/some.jsp (where project1 and myproject1 are simply paths redirecting me to my application) I have searched the web but there seems to be no specific or clear answer for this. If you know, please be detailed and include also specific code I have to write in what file.

Thanks

Andi
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look for docBase in the Context documentation.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Andi Pema
Greenhorn

Joined: Jul 14, 2006
Posts: 3
The context documentation does not help much. It is very unclear and no examples provided. I need something more specific.

Please help

Varsha Patil
Greenhorn

Joined: Jun 16, 2006
Posts: 19
In Tomcat's server.xml you can make the following entries

<Context path="/project1" reloadable="true" docBase="C:\MyDocuments\project1\jspfiles" workDir="C:\MyDocuments\project1\work"/>


The path defines the URL path that this context is for. In this example, that would be http://www.localhost:8080/project1/.

docBase specifies where the web application is to be found
Andi Pema
Greenhorn

Joined: Jul 14, 2006
Posts: 3
Thank you very much Varsha,

I have Tomcat 5. In this version they discourage using the context tag inside server.xml. Instead they have a separate file called context.xml where the contexts should be put in. I tried to put it in there and it did not work. Once I put it in the server.xml it worked fine. I had to do one change to your suggestion. The "My Documents" folder is not found directly in the C:\ directory but under \Documents and Settings directory.

Thanks anyway, I appreciate it

Andi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using a different context directory than the default webapps in Tomcat 5