A.The init method on a filter is called the first time a servlet mapped to that filter is
invoked.
B.Filters associated with a named servlet are applied in the order they appear in the
web application deployment descriptor file.
Correct Answer-B
I think answer should be A as init method is the first method that is called before servicing any request.
and IF there is a url pattern ,named servlet are applied after them irrespective of their order in DD. ----------------------------------------------------------------------------------------------------------------------
RequestDispatcher
2)
Servlet dispatches the
request to the order Work servlet that is mapped in DD to /WEB-INF/Work.do
which of the following is correct ?
A.
B.
Correct answer is B
why cant A be correct answer.
There seems to no syntax error for the code in option A.
1. B is the answer, A is wrong because the init method of Filter is called only once at deployment time when the Filter is loaded by the Container (just like the init method of Servlet), it will never be called again by the container unless you redeploy your app.
2. B is the answer, A is wrong because RequestDispatcher has no method named forwardRequest.
Choice B is not safe, if the variable jURL contains an invalid characrer for a URL like space then forwarding the request using this invalid URL would result the forward to fail.
This is only an assumption. If there's a guarantee that jURL will never contain an invalid character then it would be safe to use choice B.