• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting the locale from a jsp page

 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic