| Author |
SCWCD Questions on Filters and RequestDispatcher
|
mohitkumar gupta
Ranch Hand
Joined: May 18, 2010
Posts: 517
|
|
SCWCD Mock Exam
FIlters
1) which of the following is True ?
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.
|
OCPJP 6.0 93 %
|
 |
max ramos
Greenhorn
Joined: Jan 31, 2011
Posts: 4
|
|
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.
|
OCJP6 OCJSPSD6
|
 |
mohitkumar gupta
Ranch Hand
Joined: May 18, 2010
Posts: 517
|
|
hi max,
Option A of the second question , I had posted was wrong.The correct one is the following
A.
B.
Which one is TRUE?
|
 |
max ramos
Greenhorn
Joined: Jan 31, 2011
Posts: 4
|
|
I have to go with choice A.
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.
|
 |
mohitkumar gupta
Ranch Hand
Joined: May 18, 2010
Posts: 517
|
|
max,
If the jURL doesnot contain any invalid character,then
why can't A be choosen as the correct answer compared to B ?
Does
performs any special thing to T
Please provide some explanation.
|
 |
mohitkumar gupta
Ranch Hand
Joined: May 18, 2010
Posts: 517
|
|
why can't A be choosen as the correct answer compared to B ?
Does format performs any special thing to T parameter.
Please provide some explanation.
|
 |
 |
|
|
subject: SCWCD Questions on Filters and RequestDispatcher
|
|
|