Reputation: 14279
I have a JSP page at an address like this:
When I output request.getRequestURL()
, I get something totally different:
Note the domain changed to an IP and /foo/bar
is missing. How do I get the true URL that the browser requested using JSP?
Upvotes: 0
Views: 1016
Reputation: 16184
You can use the following to get a rewritten URL excluding domain:
String rewrittenURL = request.getHeader("REDIRECT_URL");
Upvotes: 0
Reputation: 1108537
This can happen if there is a proxy (such as Apache HTTPD) in front of the Java EE server. The particular proxy could (should) have set the original request URL as a request header. At least, all self-respected proxies do that.
You can crawl through all request headers as follows to find it out:
for (String name : Collections.list(request.getHeaderNames())) {
System.out.println(name + "=" + Collections.list(request.getHeaders(name)));
}
Upvotes: 1