tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Baker" <robertba...@charter.net>
Subject (SOLVED) Location of application-specific properties files
Date Wed, 07 Aug 2002 22:50:20 GMT
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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message