Solved

Internationalization (JSP)

Posted on 2003-11-20
6
912 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
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!

 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Retrieving file from bytes array in spring mvc 8 63
Books that can get me started on JAVA 2 132
thymeleaf natural templating vs JSP 2 202
null output 3 58
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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