0

If a web application A requests an other Java EE web application B, is it possible to retreive the URL of the web app A (requester) from the HttpServletRequest object in the servlet's doGet() method?

Hamdi Baccara
  • 29
  • 1
  • 11
  • 1
    No. because a requester doesn't have a URL. But it has an IP address. See http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getRemoteHost%28%29 and http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getRemoteAddr%28%29 – JB Nizet May 26 '15 at 16:38

2 Answers2

0

In short:

No

Explanation:

JavaEE has no knowledge about the fact, that you're talking with an outside application or from which application the request comes in. If you need the URL of the originating web application, you need to specify and pass it as input parameter on the target application.

mp911de
  • 17,546
  • 2
  • 55
  • 95
0

While it's not likely going to work, I would look for the 'referer' in the HTTP headers. You can get the headers from the HTTPServletRequest. It may not be set correctly coming form another web service. Might be worth a try. For more info...HttpServletRequest - how to obtain the referring URL?

Community
  • 1
  • 1
George S
  • 630
  • 1
  • 4
  • 6