I'd like to handle HTML 404 errors in my web app.
I can write this:
<error-page>
<error-code>404</error-code>
<location>/view/error404.jsp</location>
</error-page>
This works perfectly, but I want to log each of the invalid urls that the users type. When I use a scriptlet in the error404.jsp like this:
<%
System.out.println(request.getRequestURL());
%>
I always get : http://localhost:8080/webApp/view/error.jsp, because the users will be forwarded to my error404.jsp from the invalid URL.
How should I get the invalid URL? Or how should I write a servlet that catch all requests that are not handled explicitly by other servlets?