GetRequestURL () HttpServletRequest does not return the exact URL

I am running a web application with the spring framework on Tomcat. My requirement is that any request coming to the server must go to one servlet. so I made the following configuration in conf / web.xml

<error-page>
    <error-code>404</error-code>
    <location>/displayMsg.do</location>
</error-page>

Therefore, when a user accesses http: // myhost / xyz , request.getRequestURL () returns http: //myhost/displayMsg.do

I think the only reason requestURL () returns this url is due to the configuration of the error page I made. Maybe because tomcat is rewriting the URL of this line.

Is it possible to get the exact url in this case? Please, help

+3
source share
1 answer

.

url,

request.getAttribute(\ "javax.servlet.forward.request_uri \" ). ToString()

+1

Source: https://habr.com/ru/post/1791488/


All Articles