You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "K. Harvatis" <kh...@mail.ekke.gr> on 2003/11/13 09:12:55 UTC

File location - read/written by servlets

Hi all,

I am trying hard to find some setting or configuration regarding the
location of files used by servlets. So far I can see that the default
directory is \bin. Is there a way to set this directory elsewhere?

10q

Kostas Harvatis
-----
National Center for Social Research - Directorate of Research Support
www.ekke.gr




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: File location - read/written by servlets

Posted by Harry Mantheakis <ha...@mantheakis.freeserve.co.uk>.
Hello

If it is temporary files that you are interested in, the ServletContext has
an attribute named 'javax.servlet.context.tempdir' which will get you a
'java.io.File' object with a preset directory.

Regards

Harry Mantheakis
London, UK


> When opening files for writing you need to use absolute paths. Because at any
> given time, any servlet, jsp can change the working directory which affects
> the entire JVM. As to getting a directory to write to, use a configuration
> parameter in any of the following ways, each way having its own
> advantage/disadvantage:
> - Use a system property at startup
> - Use a JNDI Property resource defined in server.xml
> - Use a configuration parameter in web.xml
> - Use a properties file at a "well known location" which can be found in a
> webapp via ServletContext.getResourceAsStream()
> 
> -Tim
> 
> K. Harvatis wrote:
>> Hi all,
>> 
>> I am trying hard to find some setting or configuration regarding the
>> location of files used by servlets. So far I can see that the default
>> directory is \bin. Is there a way to set this directory elsewhere?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: File location - read/written by servlets

Posted by Tim Funk <fu...@joedog.org>.
When opening files for writing you need to use absolute paths. Because at any 
given time, any servlet, jsp can change the working directory which affects 
the entire JVM. As to getting a directory to write to, use a configuration 
parameter in any of the following ways, each way having its own 
advantage/disadvantage:
- Use a system property at startup
- Use a JNDI Property resource defined in server.xml
- Use a configuration parameter in web.xml
- Use a properties file at a "well known location" which can be found in a 
webapp via ServletContext.getResourceAsStream()

-Tim

K. Harvatis wrote:
> Hi all,
> 
> I am trying hard to find some setting or configuration regarding the
> location of files used by servlets. So far I can see that the default
> directory is \bin. Is there a way to set this directory elsewhere?


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org