wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt on send Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt on send Error" Watch "Doubt on send Error" New topic
Author

Doubt on send Error

Swetha S
Greenhorn

Joined: Dec 06, 2006
Posts: 16
This is question from Enthuware mock test

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?

Select 2 correct options
a Catch the exception and use RequestDispatcher to forward the request to the error page.
b Don't catch the exception and define the 'exception to error-page' mapping in web.xml
c Catch the exception, wrap it into ServletException and define the 'business exception to error-page' mapping in web.xml
d Catch the exception, wrap it into ServletException, and define the 'ServletException to error-page' mapping in web.xml
e Don't do anything, the servlet container will automatically send a default error page.

The answer is a and c. I always get confused, Why cant 'd' be the answer?

Can we wrap the exception in to ServletException and then define Servlet exception instead of Business Exception?

What happen if we have to <exception-type>ServletException<exception-type>
<exception-type>BusinessException<exception-type> defined in web.xml.

Please clarify this.I read many times, but I could not get satisfactory answers
Sayak Banerjee
Ranch Hand

Joined: Nov 28, 2006
Posts: 292
What happen if we have to <exception-type>ServletException<exception-type>
<exception-type>BusinessException<exception-type> defined in web.xml.


I presume the
to
is two....Note that you cannot declare

It should be

Same is true for the BusinessException....should be mentioned with the fully qualified name.

Coming to your question....if you have 2 error-page elements in the DD--one with ServletException and the other with BusinessException, then even if a BusinessException is thrown, the container does not show the error page associated with the BusinessException but it shows the one associated with ServletException(since that's the exception which is actually being thrown after wrapping the BusinessException with it)....the same page is shown if a ServletException itself is thrown in any other way(say any method throwing a ServletException)....so the error page is no more a specific one for the BusinessException....that's the reason you need a 'business exception to error-page' mapping.

Hope you got it.

And yeah, I guess one of the bartenders would soon come up with a warning regarding your name....please read the naming policy and change it before they do so.


Turn on, tune in, drop out.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on send Error
 
Similar Threads
error page doubt
don't understand this question
Wrapping a business exception in ServletException in doPost()
sensible way of sending error page to the client
Q: Appropriate Exception Handling in a servlet