This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ 2 ed. Final mock exam 65 question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ 2 ed. Final mock exam 65 question" Watch "HFSJ 2 ed. Final mock exam 65 question" New topic
Author

HFSJ 2 ed. Final mock exam 65 question

Kiril Nugmanov
Ranch Hand

Joined: Jul 09, 2008
Posts: 42
A programmer is creating a filter for a Java EE web application. Given the following code:

What change(s) are necessary to create a valid filter? (Choose all that apply.)
A. No changes are necessary.
B. A destroy() method must be added.
C. The doFilter() method’s body must be changed.
D. The init() method’s signature must be changed.
E. The doFilter() method’s arguments must be changed.
F. The doFilter() method’s exceptions must be changed.

Book marks B C D and E as correct but as my opinion C is incorrect - filters can block request, make redirects ans dispatches. Call of chain.doFilter() method is not necessary.

Am I correct?

SCJP5, SCWCD5, SCBCD5, OCPJWSD5, OCMJEA 5
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Kiril.
A programmer is creating a filter for a Java EE web application.

I think, the body must be changed. Here the question is for a Java EE web application. This means, the application deals with http protocol. Thats why, the body must include,
Kiril Nugmanov
Ranch Hand

Joined: Jul 09, 2008
Posts: 42
Hi Chinmaya Chowdary,

But Your described actions are not mandatory. Filter can easily deals with ServletRequest and ServletResponse - everything depends on the logic that will be placed in that filter.

But as example of blocking filter:


just outputs to the console message(that can be just commented in the filter) and it still will be working and correct - if purpose of it - block requests.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Kiril. If we don't use the following code in doFilter(), the filter is valid one and will run without any problems.

Here the question is
A programmer is creating a filter for a Java EE web application.

It means the application deals with http protocol. So we need to change the code inside doFilter() method inorder to deal with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFSJ 2 ed. Final mock exam 65 question
 
Similar Threads
nice q from jiris mock exam
Question 65 Final mock exam - HFSJ
HF: Filters and Wrappers question
Which about filters are true? Head first servlet question 5 page 735
Filter Question