Which of the following is a sensible way of sending an error page to the client in case of a business exception that extends from java.lang.Exception?
C. Catch the exception, wrap it into ServletException and define the 'business exception to error-page' mapping in web.xml----Answer
D.Catch the exception, wrap it into ServletException, and define the 'ServletException to error-page' mapping in web.xml
Why D is not an answer?
We have wrapped our business exception in ServletException and throwing ServletException so web.xml should have ServletException to error-page mapping.
Why C is correct? Since we are throwing ServletException why the mapping in web.xml should be businessException to error-page
Yes. And i read the "sensible way " in question .
But we are throwing a servletException and catching a business exception.
Or is it not the way it appears and it is actually business exception being thrown?
If no error-page declaration containing an exception-type fits using the
class-heirarchy match, and the exception thrown is a ServletException or
subclass thereof, the container extracts the wrapped exception, as defined by the
ServletException.getRootCause method. A second pass is made over the error
page declarations, again attempting the match against the error page declarations,
but using the wrapped exception instead.
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!