Christoph Rooms wrote:

> Hi Greg,
>
> You can use the CLASSPATH to load properties files ...
>
> Properties p = new Properties();
> java.io.InputStream is;
>
> is = getClass().getResourceAsStream("rnb.properties");
> if (is == null)
>     throw new Exception("Properties file not found");
> p.load(is);
>
> This works fine !
>

This approach works fine, and can be used to load properties files that are
embedded in your WEB-INF/classes directory, or inside a JAR file inside
WEB-INF/lib (or anywhere on the classpath for Tomcat).

There is an additional option that can read any static resource in your WAR
file.  For example, you can read the "web.xml" file like this:

    InputStream is =
        getServletContext().getResourceAsStream("/WEB-INF/web.xml");

which will work even in servlet containers that run your application directly
out of a WAR file (instead of an unpacked directory structure like Tomcat does).

>
> greetz, christoph
>

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to