Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Properties file path

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi,

I have jsp pages, running in Tomcat in the folder tomcat_root\webapps\ROOT\dev_folder\proj_folder, that uses property files to populate text and labels (so i can go between french and english).

When I access the page, i get a "java.util.MissingResourceException: Can't find bundle for base name home, locale en" error.

But the property file is there. Is there a specifc place i should put the file? Can I set a property file location?

Here's my jsp scriptlet:

Code:
<%
    //vars
    PropertyResourceBundle labels;
    Locale currentLocale;
    
    //get the locale from the session
    //currentLocale=(Locale)session.getAttribute("locale"); 
    currentLocale=Locale.ENGLISH; 
           
    //open the property files and get the tags.
    labels=(PropertyResourceBundle)PropertyResourceBundle.getBundle("home",currentLocale);
        
    //set the label bundle as session attribute
    session.setAttribute("labels",labels);
%>

<h3><% out.println(labels.getString("home.title.text.t1")); %></h3>
 
Properies files for resource bundle should be placed in your class path. In your case:

tomcat_root\webapps\ROOT\WEB-INF\classes\home_en.properties
tomcat_root\webapps\ROOT\WEB-INF\classes\home_fr.properties

Resourse file are teated just like class files.

For example: if your put your properties files in:
tomcat_root\webapps\ROOT\WEB-INF\classes\mypackage\home_en.properties

then you get the bundle by:

PropertyResourceBundle.getBundle("mypackage.home",currentLocale);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top