views:

758

answers:

1

I have set-up tomcat to catch all my exceptions and pass them to a servlet with the following in web.xml.

<servlet-mapping>
    <servlet-name>exception</servlet-name>
    <url-pattern>/exception</url-pattern>
</servlet-mapping>
<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/exception</location>
</error-page>

This works fine and I have the servlet logging some information and forwarding to a jsp. However I want to log the URI which caused the exception to be thrown and when I call request.getRequestURI() I get /exception which is my servlet path that's handling logging the exception. How can I get the original URI that caused the exception?

+1  A: 

You can get the original uri with

request.getAttribute("javax.servlet.forward.request_uri")
Chris