| Author |
Redirect the request
|
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 832
|
|
How can you redirect the request from a servlet to another resource if the servlet encounters an exception? a. This cannot be done unless the exception is caught in the servlet. This answer is wrong but it should be right, i don't know this answer is the wrong answer. 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.
|
SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
|
 |
Vishal Chugh
Ranch Hand
Joined: Oct 27, 2007
Posts: 177
|
|
Hi, I think answer would be A,C .Is it? Could you please confirm? Thanks Vishal Chugh
|
 |
vipin jain
Ranch Hand
Joined: Aug 24, 2008
Posts: 122
|
|
|
I think answer would be A.
|
Best Regards,<br />Vipin<br />MCA, SCJP5, SCWCD in progress
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Originally posted by Amandeep Singh: d. This can be done even if the exact class of the exception is not known at compile time.
Hi dude Amandeep Singh, It seems to be correct
|
 |
Archana Venkatesh
Greenhorn
Joined: Sep 02, 2011
Posts: 4
|
|
Hi,
Even I am not clear about the answers to this question. I think A and C are correct answers.
Is there a way to specify a mapping between exception class and resource in web.xml ??? ( as mentioned in the Option B )
I guess this can be done only for JSPs by configuring <error-page> tag. Can this be done for servlets too ???
Thanks,
Archana
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
Is there a way to specify a mapping between exception class and resource in web.xml ??? ( as mentioned in the Option B )
I guess this can be done only for JSPs by configuring <error-page> tag. Can this be done for servlets too ???
Yes, this also works for Servlets (have a look at the specs ans search for error handling).
Just create a Servlet yourself and throw a ServletException from it:
like:
and define an entry in your web.xml like:
You will be redirected to your error page as soon as your Servlet throws the ServletException.
Regards,
Frits
|
 |
 |
|
|
subject: Redirect the request
|
|
|