tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Sidney-Woollett" <joh...@wardbrook.com>
Subject Re: directory reference
Date Fri, 28 Nov 2003 21:41:47 GMT
Why not use a Properties file which you can get the class loader to locate
for you using call similar to:

properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/myfile.properties"));

Just place the file at the root level of your (web project) source tree,
so that it is copied either to WEB-INF/classes or built into a jar file
placed in WEB-INF/lib when your app is deployed.

Make sure that the path to the file matches the directory (or package
folder) that you place the properties file in.

This technique works fine with Tomcat, or with a regular java app.

John Sidney-Woollett

Giorgio Franceschetti said:
> Hi all,
>    I'd like to create a file with some configuration details for my
> application.
> I tryed to reference my file like this "./data.txt" and I found it in my
> tomcat/bin directory.
> Well, I should  have expected this, quite like any other java
> application points to the executable directory.
> Is there any way to point to my application directory?
> Should I assume a fixed path like tomcat/webapps/myapp    ?
> Thanks in advance,
>     Giorgio
>
>
>


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


Mime
View raw message