Page 1 of 1
About Question enthuware.jwpv6.2.648 :
Posted: Mon Jan 14, 2013 2:50 pm
by gurpreet_asrgndu
why are the last 2 options not correct ? no explanation has been provided for them. plz help
Regards
Gurpreet
Re: About Question enthuware.jwpv6.2.648 :
Posted: Mon Jan 14, 2013 3:09 pm
by admin
The last 2 options are not correct because they are opposite to option 1 and 2, which are correct, i.e. you should throw the appropriate exceptions from the init method (and not from the service method). So both can't be correct.
HTH,
Paul.
Re: About Question enthuware.jwpv6.2.648 :
Posted: Fri Jan 18, 2013 12:26 pm
by gurpreet_asrgndu
that is what my question is .why shouldnt we throw exceptions from the service method ?
Re: About Question enthuware.jwpv6.2.648 :
Posted: Fri Jan 18, 2013 1:03 pm
by admin
Because if the servlet is not initialized, how will you execute the service method? If the problem is with initialization, the exception should be thrown from the initializer. Why would you throw it from service??
Remember that when the servlet container initializes a servlet there may not be any request at all.