How to get the source url / uri of the page after sending the query manager

I have Error404Servlet, which is configured as an error page for 404 in web.xml:

   <servlet>
      <servlet-name>Error404</servlet-name>
      <servlet-class>com.foo.bar.Error404Servlet</servlet-class>
   </servlet>

   <error-page>
      <error-code>404</error-code>
      <location>/error404</location>
   </error-page>

In this servlet, I need to register the source url that called 404, but request.getRequestURI () always returns "/ error404"

How can I get the source url? A terrible ugly method that I know is to create a filter that sets the source url for the attribute request.

+3
source share
1 answer

In the request, you can get the attributes set by the container in case of an error:

request.getAttribute("javax.servlet.error.request_uri");

other attributes that may provide useful information;

javax.servlet.error.status_code
javax.servlet.error.exception_type
javax.servlet.error.message
javax.servlet.error.exception

. 2.3 .

+11

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


All Articles