This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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.
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. Bill