aspose file tools*
The moose likes Servlets and the fly likes how to get the client's bowser URL who's hitting your service from ajax call? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to get the client Watch "how to get the client New topic
Author

how to get the client's bowser URL who's hitting your service from ajax call?

subodh gupta
Ranch Hand

Joined: Jul 23, 2007
Posts: 203
I have a service which is being hit by a ajax call from the client i need to know there web address is there any way to do this?


http://subodh-gupta.blogspot.com
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

check the referer HTTP header
http://en.wikipedia.org/wiki/HTTP_referrer

This value is not 100% correct since clients can block or fake it, but it is your best and easiest guess.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
javax.servlet.ServletRequest#getRemoteAddr()


Ping & DNS - updated with new look and Ping home screen widget
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The OP is asking for the browser URL, not the client external IP
subodh gupta
Ranch Hand

Joined: Jul 23, 2007
Posts: 203
@Ulf i am not looking for IP

@David this is not fool proof so many a times i might get nothing
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Do you also provide the JS that creates the Ajax call? you could use that to get the client URL and return that value in the the Ajax payload. People may not like it and could consider it 'snooping'.
Personally I'd stick with the referer unless it was proven to be unreliable.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
subodh gupta wrote:@Ulf i am not looking for IP

I see. "web address" *can* mean the IP address, though.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Yeah, "web address" is pretty ambiguous.

In any case, why do you need this? Maybe there's another way to solve the proble.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the client's bowser URL who's hitting your service from ajax call?
 
Similar Threads
How to execute Servlet Method using java Script
Ajax Query related to request and response
[AJAX] Web Application logical division
Struts 2 with AJAX Call
Passing/Accssing HttpSession to service layer