I may not have framed the query properly. So let me explain the problem I am facing.
Environment :
I have a server which responds to http API calls. The client making this call, is an html file on another server. So it is a cross domain call. The functionality is working as expected.
Problem :
On my webapp (tomcat servlet), I want to be able to get the domain name of the client, making this call
Example :
If http://abc.com/crossDomainCall.html is making the cross domain call to my server, I want to be able to see that it is abc.com
What I have tried :
I have tried request.getRemoteAddr() and request.getRemoveHost()
But they are returning the server address which was servicing the HTML at that point of time. Not the server address which is hosting the html (abc.com)
Any pointers on this, will be really appreciated.
Cheers,
Rohitesh
Edit 1 :
As @gigadot replied, using 'referer' from HTTP Header, is working for me. But this is not fool proof. So, my question is, how do services like Google Maps do this? I know, that they need to compare an API key, with the corresponding domain which has registered that key. So, how do they verify something like this?