• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error page doubt

 
Ranch Hand
Posts: 392
  • 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?

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
(You can use this approach only if the business exception extends from RuntimeException.)

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

d)Don't do anything, the servlet container will automatically send a default error page.
(This will happen only if you call response.sendError(...) method.)

Ans Given As : a and c
I think the ans should be a) and b)

Also the following statement is incorrect:

Don't catch the exception and define the 'exception to error-page' mapping in web.xml
(You can use this approach only if the business exception extends from RuntimeException.)


I have seen the code
<error-page>
<exception-type>java.lang.Throwable </exception-type>
<location>/error.jsp</location>
</error-page>
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Javaranchers,
Still No Reply !!!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sandeep Vaid:
Javaranchers,
Still No Reply !!!



Patience Is A Virtue
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DD is d bestest way ..
i guess d ans shd only b b) ..
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sandeep, please QuoteYourSources

"Listener event", on your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
reply
    Bookmark Topic Watch Topic
  • New Topic