Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error page doubt

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Javaranchers,
Still No Reply !!!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sandeep Vaid:
Javaranchers,
Still No Reply !!!


Patience Is A Virtue
 
Asif
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DD is d bestest way ..
i guess d ans shd only b b) ..
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic