You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Robert Baker <ro...@charter.net> on 2002/08/08 00:50:20 UTC

(SOLVED) Location of application-specific properties files

The first of your three examples below works just great.  I haven't tried
the other two yet, but I will.

Thanks!
Bob

-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]

Since you want to avoid this so that your app is not servlet specific, you
can do the following....

load(CurrentClass.class.getResourceAsStream("/myprops.properties"));

or

load(CurrentClass.class.getClassloader().getResourceAsStream("myprops.proper
ties"));

or

load(Thread.currentThread().getContextClassLoader().getResourceAsStream("myp
rops.properties"));


Notice in all the cases where you are looking in the classpath/classloader,
you do not reference "WEB-INF" or the "classes" directory within
WEB-INF.  The classloader doesn't know about those.  The ServletContext, on
the other hand, knows about everything inside the root of the current
webapp.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>