Reputation: 1492
I am running a spring framework based web app on Tomcat. My requirement is that any request coming to the server should come to a single servlet. so i made the following configuration in conf/web.xml
<error-page>
<error-code>404</error-code>
<location>/displayMsg.do</location>
</error-page>
So when the user access http://myhost/xyz , request.getRequestURL() returns http://myhost/displayMsg.do
I think the only reason for the requestURL() to return this url is because of the the error page configuration i made. May be because tomcat overwriting the url to this string.
Is it possible to get the exact URL in this case? Please help
Upvotes: 3
Views: 4156
Reputation: 166
I ran into this same problem a couple weeks ago.
You can pull the actual url using
request.getAttribute(\"javax.servlet.forward.request_uri\").toString()
Upvotes: 1