File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes SCWCD Questions  on Filters and RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "SCWCD Questions  on Filters and RequestDispatcher" Watch "SCWCD Questions  on Filters and RequestDispatcher" New topic
Author

SCWCD Questions on Filters and RequestDispatcher

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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%
OCPJWCD 5.0 98%
max ramos
Greenhorn

Joined: Jan 31, 2011
Posts: 7

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 OCWCD6 OCEJBD6 OCJPAD6
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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: 7

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.
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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.
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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