Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Handling

 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please verify the answers to this question:
How can you redirect the request from a servlet to another resource if the servlet encounters an exception?
Select 2 correct options
a.This cannot be done unless the exception is caught in the servlet.
b.By specifying a mapping between exception class and the resource in web.xml.
c.This can be done only if the exception is a subclass of javax.servlet.ServletException.
d.This can be done even if the exact class of the exception is not known at compile time.
The answer says 'B' & 'D' are the correct options.
Isn't 'A' correct option too since to redirect the request from a servlet to another resource if the servlet encounters an exception we use include or forward method of RequestDispatcher to include or forward to another resource and this cannot be done unless the exception is caught in the servlet.
Thanks
Ravi
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
There is a mistake in what has been mentioned in above question.
The correct options are B & C.
According to me A should also be a correct option. Offcourse the question says select two options.
Thanks
Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic