On Wed, 1 Aug 2001, Jim Cheesman wrote:

> At 10:56 PM 31/07/01, you wrote:
> 
> >Where does tomcat expect to find the *.properties files.  I've got a class
> >that fails with it's ResourceBundle call to a properties file.  I've tried
> >it in the WEB-INF and WEB-INF/classes directories for the specific web app.
> 

Where to put them depends on what APIs you are using to read them.  There
are two fundamental choices:

If you use ServletContext.getResource() or
ServletContext.getResourceAsSteram(), you put them somewhere in your web
application directory hierarchy, and use a context-relative path starting
with a "/" to read them (just like you would pass to a request
dispatcher).  For example, to read the web.xml file, you could say:

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

On the other hand, if you want to use Class.getResource() or
Class.getResourceAsStream() to read them -- this is what the
java.util.ResourceBundle family of classes do -- then you need to place
the files under WEB-INF/classes, or in a JAR file under WEB-INF/lib, in
exactly the same place that you would put a corresponding Java class file.

The simplest use case would be a resource bundle named "messages", where
you have files "messages_en.properties", "messages_fr.properties", and so
on.  These files would go under /WEB-INF/classes.

> 
> In tomcat 4.0b6 on Win2000 I'm using properties files that are in a jar 
> file in WEB-INF/lib.
> 

This is equivalent to putting them unpacked under WEB-INF/classes.  The
key issue is that the package naming hierarchy has to match the directory
structure inside the JAR (just like with class names).

Could you post a specific example of the ResourceBundle.getBundle() call
you are making, and where you have placed the corresponding properties
files?

> 
> 
> Jim
> 

Craig McClanahan

Reply via email to