• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpServlet getLocale()  RSS feed

 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,

Need your help. I am going to work on an i18n application. I need to know user (broswer's) Locale.

Which one is good to use

getLocale() method of HttpServletRequest

OR

getHeader("Accept-Language") of HttpServletRequest


Please suggest.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what the method returned when running on my local computer:

request.getLocale()=en_US
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by steve souza:
Here is what the method returned when running on my local computer:

request.getLocale()=en_US


getLocale gives the local of the client as you might be using the browser is the same computer so you are getting so.

You can set you browser settings for japannese language and then the value returned from getLocal would change.

When a request comes into the server , the server uses the request headers to decide the local and set it in the request.
 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to everyone
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!