cgray1223
asked on
Servlet Container Exception Handling
Hello,
I have a J2EE application running on Tomcat 7 with log4j implemented. I wanted to create a custom error page whenever my application encounters an Exception. I created something similar to ex #1 below in my web.xml, but I was wondering If I can just catch all errors. I don't think its possible since 500 is java.lang.Throwable and wont get caught if I try to use and exception-type condition (see #2 below).
ex#1
ex#2
I have a J2EE application running on Tomcat 7 with log4j implemented. I wanted to create a custom error page whenever my application encounters an Exception. I created something similar to ex #1 below in my web.xml, but I was wondering If I can just catch all errors. I don't think its possible since 500 is java.lang.Throwable and wont get caught if I try to use and exception-type condition (see #2 below).
ex#1
<error-page>
<error-code>404</error-code>
<location>/errors/error.jsp</location>
<error-code>500</error-code>
<location>/errors/error.jsp</location>
</error-page>
ex#2
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/errors/error.jsp</location>
</error-page>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, I think you are right - you cannot trap every error that could ever occurs - there will be alwyas something which you had not anticipated
ASKER