• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Doubt in a Mock Exam Question...

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

1)Catch the exception and use RequestDispatcher to forward the request to the error page.
2)Don't catch the exception and define the 'exception to error-page' mapping in web.xml
3)Catch the exception, wrap it into ServletException and define the 'business exception to error-page' mapping in web.xml
4)Catch the exception, wrap it into ServletException, and define the 'ServletException to error-page' mapping in web.xml
5)Don't do anything, the servlet container will automatically send a default error page.

The given answers are 1 & 3.
I can't understand why answer 4 is wrong? can anyone explain a bit on this?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Saran!

In (3) you can choose to have different error page to forward to for different types of business exceptions.

But in (4) for any type of business exception you will be able to forward only to the error page specified in mapping against ServletException.If this is what you want then (4) is also correct. But generally you would want to forward to error page depending on the type of business exception.
 
saran ram
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ooook...I got it. Thank you Nilesh.
 
Hug your destiny! And hug this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic