It's not a secret anymore!
The moose likes JSF and the fly likes Properties file outside the WAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Properties file outside the WAR file" Watch "Properties file outside the WAR file" New topic

Properties file outside the WAR file

zabin shariff

Joined: Jun 03, 2010
Posts: 19
Hi there.

My requirement is to implement internationalization with the properties file outside the WAR. I referred so many websites and forums for this, but could not find a solution. All the forums say about ClassLoader and getResourceAsStream("full url"). I am not able to do this (getting null pointer exception). Moreover I am wondering, even if it works how can I use this in my jsp. Does anybody have any idea so as to how can I access a properties file which is located outside the WAR and still can call a syntax like in my jsf page.

Please help
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17145

Funny you should ask.

For I18N you should pair the techniques discussed in that thread with the message bundle capabilities of Java. There are specific options in the faces-config.xml file to help with that, and a little searching should turn up some good examples of best practices using message bundles and JSF.

An IDE is no substitute for an Intelligent Developer.
Damian Cardozo

Joined: Aug 04, 2011
Posts: 10
Hello, I know this is a little late, but this is how I did it (using Tomcat 6).

I 'conf' folder (inside tomcat installation dir) there is a file ''. this file has a property called "shared.loader". set this property with the path of the folder where you put your i18n files. this path may not contain spaces. Also use "/" instead of "\". for example:


then in each xhtml page (or even better, in your template) put this:

<f:view locale="#{localeBean.locale}">
<f:loadBundle basename="filename" var="text" />

where "filename" is the name of your i18n files, so you'll have for example "", "", "" etc..
localeBean is a session scoped managed bean that has a property with the current locale.

you could place the bundle configuration in faces-config, but the problem with this approach is that then you won't be able to clear the cached files, so if you update the language files (change a translation) you won't see the changes in you app.
using f:loadBundle, after a simple call to ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader()); your i18n files will be reloaded, reflecting any changes you've made.


Janaka Nawagamuwa

Joined: Aug 20, 2012
Posts: 1
Agree to Damian's reply....
For more info, go to following link...

This is working for me.
I agree. Here's the link:
subject: Properties file outside the WAR file
It's not a secret anymore!