Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Andi Pema
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
 
Andi Pema
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic