• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting the locale from a jsp page

 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,Can I get the locale of a user who is requesting my jsp page from adifferent country?In short I want to fiind out from which country the request is coming.Can i do it in JSP?
Thanx,Vedhas
 
Ken Robinson
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything you can do in Java you can do using JSP. Remember, the container will just compile your JSP page (static HTML, tags and scriptlets) into a Servlet.
The method ServletRequest.getLocale() will return the user's Locale if it was supplied from the client (web browser).
So, a bit of code like...
<% Locale l = request.getLocale(); %>
...should do it.
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,Thanks for the reply.'m doing this :
<%
Locale l = request.getLocale();
out.println("LOCALE :"+l+"country "+l.getDisplayCountry());
%>
The output is :
LOCALE :en_US country United States
I'm making the request from India ,my webserver & database server are both in India.PLz help me out.
Thanx again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!