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.
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.
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 'catalina.properties'. 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:
where "filename" is the name of your i18n files, so you'll have for example "filename_en.properties", "filename_es.properties", "filename_fr.properties" 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.