tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lempinen Sami (NET/Tampere)" <>
Subject Re: loading a properties file - where does it expect the file to be?
Date Wed, 27 Sep 2000 08:44:11 GMT
On Tue, Sep 26, 2000 at 11:22:48PM -0500, EXT Jacob Kjome wrote:

> I have a servlet that uses another class that isn't a servlet which loads a 
> file with properties in it.
> When I run the class as an application, it works fine.
> However, when calling it from a servlet, it can't find the file???

How are you specifying the path to the properties file? The concept of
working directory is different from the servlet context path.

Solution: either specify the path relative to the servlet context path
as in 

   // Obtain the servlet context.
   con = getServletContext();

   String path = con.getRealPath("/")
                 + System.getProperty("file.separator")
                 + con.getInitParameter("propfile")

or use a ResourceBundle which can be located anywhere in your

Sami Lempinen <>
OSS Monitor / NMS Infoware Technologies
Blame Canada.

View raw message