This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Internationalization of web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Internationalization of web service" Watch "Internationalization of web service" New topic
Author

Internationalization of web service

Johannes Thorén
Ranch Hand

Joined: Nov 18, 2008
Posts: 64
I'm facing a problem where i have to internationalize a web service.

I have x number of .jsp files, where i present for example:

"Enter your surname:"
"Enter your e-mail".. and so on.

And i wonder if there is any simple way to change language by for example clicking a button.
The krux is that i have to use the same file, so I'm thinking, maybe there is a way to have 2 files with properties, same name of the properties
but the value is on 2 different language, and then when you click the button you simply read the properties from one file or the other?

Is this possible, if so, how do i implement it? :-)

Kind regards,
Drace
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

You may have two different property files to be served based on the language change. The same behavior is being followed in frameworks like struts. It would not be a recommendation to use same file for different language.


No pain, No gain.
OCJP 1.6
Johannes Thorén
Ranch Hand

Joined: Nov 18, 2008
Posts: 64
Kumaravadivel Subramani wrote:You may have two different property files to be served based on the language change. The same behavior is being followed in frameworks like struts. It would not be a recommendation to use same file for different language.


I found a solution using propertyfiles.
Awesome! :-)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Check out the <fmt:message> JSTL tag.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Johannes Thorén
Ranch Hand

Joined: Nov 18, 2008
Posts: 64
I fixed the language problem, but one issue still remains. Now when i change the language using JSTL it changes for the webpage that i'm on. How can i make the language selection to be implementet on every page, when i brows to other pages on the same site?

I guess there must be some kind of way to send a value between pages and when the next page is about to load, checks "what language?".

Kind Regards,
Johannes
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Store the language selection in the user's session.
Johannes Thorén
Ranch Hand

Joined: Nov 18, 2008
Posts: 64
Bear Bibeault wrote:Store the language selection in the user's session.


Could you be more specific please, I'm a total newcommer on this area. The code i have in my JSP-files right now are:






And then everything with dynamic language presented like:


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Right now, it looks like you are getting the language value from the parameters. Rather, once you know it, store and retrieve it from the session
Johannes Thorén
Ranch Hand

Joined: Nov 18, 2008
Posts: 64
Bear Bibeault wrote:Right now, it looks like you are getting the language value from the parameters. Rather, once you know it, store and retrieve it from the session


Is that possible to do in a Spring project, the language works perfect between pages, exept for my interceptor. Since that url is set in an xml file.

How can i reach the session to save it?

Kind regards,
Drace
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internationalization of web service
 
Similar Threads
live editing of Properties
FileInputStream creating a new File ??
how to write java web service client
Internationalization
Web Interface to edit Properties file