This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat "working directory"" Watch "Tomcat "working directory"" New topic

Tomcat "working directory"

adrian calvin

Joined: Apr 07, 2005
Posts: 1

1) I have struggled with this for days. I DAFS many many times and still have not gotten it worked out. I need to know how to change the working directory Tomcat uses. This is important to me, since I would like to use _relative paths_ when accessing local resources on the server, like text files. What really makes this a problem is I have potentially 50 servers I will need to deploy to, and so far, although my apps work fine in my development environment( Netbeans ) they are not working when I deploy. And if I mak changes like using absolute paths, or 'getRealPath' method, they work remotely but not in my development environment. This is my main issue.

2) On a side note, I notice when developing web apps in Netbeans, Netbeans puts an absolute path for the _docBase_ in the _context.xml_ file. This is very annoying because I have to edit the file manually _OUTSIDE_ of Netbeans before I deploy the app to a another server. If anyone can help with these 2 questions I would be very happy. Thank you.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You can not use ANY file operations that depend on the operating system "working directory." For one thing, it would conflict with other web applications.
The Servlet API provides for relative directory structure based on the location of your "web application" - this way it is completely universal and portable between servers. See the JavaDocs for ServletContext.
I can't imagine why the getRealPath method fails to work correctly in NetBeans.
If you absolutely can't use getRealPath, try configuring directories in init-parms in web.xml.
I agree. Here's the link:
subject: Tomcat "working directory"
It's not a secret anymore!