Handling exceptions in jsp

What is the diference between using

<%@ page errorPage="foo.jsp" %>

and declaring within web.xml

<error-page><error-code>404</error-code><location>/foo.jsp</location></error-page>

<error-page><error-code>500</error-code><location>/foo.jsp</location></error-page>

Which is better to use and why?

Thanks

[448 byte] By [ar.kaza] at [2007-11-26 15:30:49]
# 1
I'd go for the second, largely because if you introduce a better error page later on, it's a minor config change rather than a code change, and the re-deployment overhead that goes with it. and also you can explain to a non-programmer how to change config a lot easier than code
georgemca at 2007-7-8 21:47:34 > top of Java-index,Java Essentials,New To Java...
# 2

One point and one comment

Point: Your error page needn't be another jsp. You can just as well declare a static HTML page as the attribute to errorPage.

Comment: If you use a static page, I don't believe you can capture information about the exception thrown as you can in a jsp [via error.getMessage()].

filestreama at 2007-7-8 21:47:35 > top of Java-index,Java Essentials,New To Java...