• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 925
  • Last Modified:

Internationalization (JSP)

Hi,

I'm testing the following code in order to internationalize my application:

---------------------------------------------------------------------
      Locale locale = new Locale("de");
      ResourceBundle resources;
      resources = ResourceBundle.getBundle("Messages", locale);
      System.out.print(resources.getString("settings_settings"));
---------------------------------------------------------------------

This works in standard Java applications.
- But when the code is put into a JSP, the error message says, the resource cannot be found.

(Messages_de.properties is in the same folder as test.java, resp., test.jsp. I'm using the NetBeans IDE.)

What's wrong?

- Thanks.
0
robbert
Asked:
robbert
1 Solution
 
jimmackCommented:
Just a guess, but you should be able to test it quickly enough.

Try putting the resource file in the WEB-INF directory of your web app.
0
 
TimYatesCommented:
If that doesn't work, maybe consider using the i18n taglib from apache?

http://jakarta.apache.org/taglibs/doc/i18n-doc/
0
 
kennethxuCommented:
>> Messages_de.properties is in the same folder as test.java, resp., test.jsp. I'm using the NetBeans IDE.)
I think it should be in WEB-INF/classes dir.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jimmackCommented:
Oh.  It's in the *classes* subdirectory.

Thanks kennethxu.  I was close with my guess ;-)
0
 
robbertAuthor Commented:
Thank you, that way, it works - and please excuse that I'm trying to extend the question:

Actually, the JSP (in the root web) calls a method of a class (in WEB-INFO/somefolder/internat.java), passing the name of the properties bundle as a parameter. - Where should I put the .properties file??
0
 
kennethxuCommented:
It doesn't matter where you java SOURCE file is.
I assume you have your java class in WEB-INF/classes, then the properties file should still in the same place.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now