Great, got it, it works. Thanks.
Jerry
Daniel wrote:
Hi Jerry,
You can use:
servletContext.getRealPath("/path_relative_to_webapp_root/");
Regards, Daniel
On Sun, 1 Feb 2004, Jerry Ford wrote:
I want to write a config file from a servlet implemented in /usr/local/webserver/tomcat/webapps/myWebapp/WEB-INF/classes/my/package/myWebapp.class, to a myWebapp/conf directory. The directory exists, and there are no permissions issues---I can write the config file if I hardcode a full path to the file.
The following works:
FileWriter fwrite;
try { fwrite = new File Writer("/usr/local/webserver/tomcat/webapps/myWebapp/conf/" + project + ".conf"); // ...etc. } catch(IOException e) { // ...etc. }
But if I change the path in the new FileWriter statement to any of the following, it does not work:
/myWebapps/conf (relative to tomcat's servlets root) conf/ (relative to the docBase declared in the webapp's context) ../../../../conf (relative to the class file)
I get a FileNotFound...(No such file or directory) exception.
What does tomcat consider to be the relative path to the myWebapp/conf directory? relative to what?
BTW, this is a private, internal app that won't be deployed in a public website, so there are no concerns about writing files to the server's disk. But I want to reserve the option of deploying to a Windows machine or keeping it on the Linux box, and I don't want to be tied to a specific directory location on either box.
Thanks.
Jerry
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
