File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes get locale Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "get locale" Watch "get locale" New topic

get locale

Anthony Karta
Ranch Hand

Joined: Aug 09, 2004
Posts: 342
is it possible to get locale setting from user computer or HTTP header?

what we want to do is format the date and currency based on locale setting in user computer? is it easier we implement in Servlet or JSP?

and next thing is, we would like to display HTML text based on user language, say if someone in Japan browse our website, we show it in Japanese. what we should do to implement this?

many Thanks in advance

Susanta Chatterjee
Ranch Hand

Joined: Aug 12, 2002
Posts: 102
First, please read this.

I did a google search with the words "servlet jsp internationalization" and came up with quite a few good pages. Click here
Hussam Bamatraf

Joined: Aug 25, 2003
Posts: 14
You can get the the language preferred by an HTTP client by parsing the Accept-Language header of HTTP protocol. Example of this header:
Accept-Language: en-US; q=1.0, en;q=0.5
This header indicates that the user prefers American English (quality 1.0) but will take any form of English as an alternative (qualiity 0.5).
You can write a servlet to do internatinalization and direct user to a page according to their langauge preference.

SCJP 90%<br />FileNet Certified Professional: Content Management Developer 92%<br />FileNet Certified Professional: Business Process Management Developer 92%
I agree. Here's the link:
subject: get locale
It's not a secret anymore!