Craig - Thanks for the quick response..:)
I tried to follow what you suggested, but, neither suggestion worked. See
body of email for more details...
----- Original Message -----
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 31, 2001 8:59 PM
Subject: Re: getResourceAsStream - properties files
>
>
> On Sat, 31 Mar 2001, Java Poop wrote:
>
<snip/>
> >
> > InputStream stream =
> > this.getClass().getResourceAsStream("testApp.properties");
> >
>
> This is supposed to work if you store the testApp.properties file in
> WEB-INF/classes, *and* your servlet class itself was loaded from either
> WEB-INF/classes or WEB-INF/lib.
I'm trying this from within a simple class (which extends, implements
nothing) that I'm instantiating from a servlet. The class file is in the
/classes directory (although it is in a package --- com.company.blah). I
tried putting the properties file in the classes, lib and the actual
directory where the class is... but nothing works. I get a null stream.
<snip/>
>
> What I do for things like this is to put configuration files like this in
> the WEB-INF directory of my webapp. Then, I can call:
>
> InputStream is =
>
getServletContext().getResourceAsStream("/WEB-INF/testApp.properties");
>
> which will work when the WAR is either packed or unpacked.
So you are saying that I should put a war file in the webapps directory,
plus create a directory with the same name of the webapp and put the
properties file into the WEB-INF directory? ie, so my directory listing
would look like:
/webapps/myapp.war
/webapps/myapp/WEB-INF/myApp.properties
If myapp.war also contained myApp.properties, wouldn't the war file get
un'jard by tomcat and then overrite my file? (I would like to put a default
properties in my war file in case someone has not setup a properties file.)
Also, from within a class instantiated by the servlet, can I call
getServletContext()? Do I need to pass it in? If this class were to
eventually become a bean or taglib, what do you suggest for handling
configuration file loading.
Thanks in advance,
JP
>
> Craig McClanahan
>
>
>