aspose file tools*
The moose likes Servlets and the fly likes How to detect the territory of a request ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to detect the territory of a request ?" Watch "How to detect the territory of a request ?" New topic
Author

How to detect the territory of a request ?

Aryan The Bad Boy
Greenhorn

Joined: Jun 01, 2009
Posts: 3
How to detect the territory of a request in Struts?

Is there any way to detect that this request is from US or india or any other country or territory ?
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

Aryan The Bad Boy wrote:

Please edit your name to use a real first and last name. See the Naming Policy for more details.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Moving to Servlets; not Struts-specific.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

"Aryan The Bad Boy", please check your private messages for an important administrative matter one final time.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
I don't know if there's a simpler way, but you can get the IP address of the remote host (from the request headers), then make use of an online resource for looking up information on the IP address. I don't know of any such service off-hand, but you should be able to Google and find something.

Hope this helps.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Aryan The Bad Boy wrote:How to detect the territory of a request in Struts?

Is there any way to detect that this request is from US or india or any other country or territory ?


the complete way to do it is by using the remote user's IP address against a local or remote database
to get your own IP database that can differentiate countries based on IP, you can get a free GEO database at maxwind.com. To go beyond country, then you pay big money.

A remote service like Mark suggests will of course be easier and be able to tell you India vs United states.

Another way is to get the accept-charset and accept-language headers out of the request object and infer things from there. The request has a getLocale() method that uses the accept-language header to return the preferred locale. I don't know what the default language setting for India is. Obviously, this depends on the user's browser settings and they can easily change this.

you can also calculate the difference in hours between remote user's local time and GMT using Java Script

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to detect the territory of a request ?