Solved

Internationalization (JSP)

Posted on 2003-11-20
6
918 Views
Last Modified: 2006-11-17
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
Comment
Question by:robbert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9791372
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
 
LVL 35

Expert Comment

by:TimYates
ID: 9791932
If that doesn't work, maybe consider using the i18n taglib from apache?

http://jakarta.apache.org/taglibs/doc/i18n-doc/
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 200 total points
ID: 9793261
>> 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
Independent Software Vendors: 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!

 
LVL 15

Expert Comment

by:jimmack
ID: 9796025
Oh.  It's in the *classes* subdirectory.

Thanks kennethxu.  I was close with my guess ;-)
0
 
LVL 15

Author Comment

by:robbert
ID: 9799779
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
 
LVL 14

Expert Comment

by:kennethxu
ID: 9801191
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question