• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look for docBase in the Context documentation.
 
Andi Pema
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic