just place your .properties file under web-inf/classes which is alway guaranteed to be in your classpath... - so u are still outside of any packages...
Anoop On 8/5/05, Maciej Stoszko <[EMAIL PROTECTED]> wrote: > Thx Jon, > I had already looked at the wiki entry you graciously pointed me to. > I need a bit more. The class X, I mentioned, is already packaged and I am > looking for a way of using it without changing it (unless there is no other > way.) It makes the assumption that the ../data folder is in the classpath. > In eclipse or via ant I can easily set my classpath 'right', is there a way > to do it for the webapp inside Tomcat? > > Regards, > maciek > > PS. What does "HTH" stand for? > > -----Original Message----- > From: Jon Wingfield [mailto:[EMAIL PROTECTED] > Sent: Friday, August 05, 2005 12:28 PM > To: Tomcat Users List > Subject: Re: loading resources from the servlet. > > http://wiki.apache.org/jakarta-tomcat/HowTo#head-45c3314139cb900ddd43dde2ff6 > 71532e6e844bc > > HTH, > > Jon > > Maciej Stoszko wrote: > > I have a class X which needs to load a .properties file. > > > > Here is a code snippet: > > > > ClassLoader cl = this.getClass().getClassLoader(); > > > > InputStream stream = cl.getResourceAsStream(/data/x.properties); > > > > > > > > It works just fine from my JUnit test for X. > > > > > > > > Now, I would like this class to be called from the servlet, which would > run > > inside Tomcat 5.5.9. The only way to get that to work is to place my > > x.properties file inside the package the class X lives in. Well, I'd > rather > > not to mix properties with classfiles. > > > > > > > > Another way, I can load that file, is to use servlets getServletContext() > > method. However, that would mean I need to pass the InputStream from the > > servlets to my class X. Well, I'd rather not to change X to use its caller > > to get X's properties file. > > > > > > > > I guess, what I need to do is to add the WEB-INF or ROOT dir of my webapp > to > > the classpath, so the classloader can find it. Or is there some other way > of > > accomplishing it? > > > > > > > > I think I am missing something fundamental ... cos that doesn't seem to be > > too strange of a requirement ... > > > > Any ideas? > > > > Thanks, > > > > maciek > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Thanks and best regards, Anoop --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
