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 Doubts in HFSJ (Filters chapter) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubts in HFSJ (Filters chapter)" Watch "Doubts in HFSJ (Filters chapter)" New topic
Author

Doubts in HFSJ (Filters chapter)

Srikanth Raghavan
Ranch Hand

Joined: Oct 31, 2005
Posts: 389
Hi, I have a few doubts in the chapter-end Coffee Cram questions.

Q1) What are true about filters?

A. Some wrong answer
B. The destroy() method is always a container callback
C. The doFilter() method is always a container callback
D. The only way a filter can be invoked is through a declaration in the DD
E. Some wrong answer

I didn't understand the meaning of the option B and C. But I think if they are wrong, they both have to wrong. The correct answers are B and D. D is clear to me, but why is doFilter() not a container callback?

Q5) Which about filter are true?

A. Filters may be used to create request and response wrappers
B. Some wrong answer
C. Some wrong answer
D. Filters support an initialization mechanism that includes an init() method that is guaranteed to be called before the filter is used to handle requests.
E. Some wrong answer
F. Some wrong answer
G. A filter's doFilter() may block further request processing.

The answers are A & G. But what's wrong with D? I think D is also correct. Can anyone clarify my doubts?

Thank you,
Srikanth
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

C. The doFilter() method is always a container callback

A common trap. doFilter is a container callback in the Filter class, but it's not in the FilterChain class. You've got to call it yourself. Yes, that's a nasty question

About question 5, is it page 703 ? If so, please check the errata :
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed


[My Blog]
All roads lead to JavaRanch
Srikanth Raghavan
Ranch Hand

Joined: Oct 31, 2005
Posts: 389
Thanks Satou for clearing my doubts

Yes, it was a nasty question. It doesn't specify the context at all. And thanks for the pointer to errata. Option D is indeed, correct.

-- Srikanth
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Related to Q1 in the original post:
Assume I have a filter of class A that is instantiated and called by the container in a normal fashion. Also assume that the A filter, upon some certain condition being met, creates and calls an instance of another filter of class B that is not used in the deployment descriptor.
Perhaps it is just me, but suddenly "The destroy() method is always a container callback" does not feel entirely true any more...
Srikanth Raghavan
Ranch Hand

Joined: Oct 31, 2005
Posts: 389
Originally posted by Navi Nirsak:
Related to Q1 in the original post:
Assume I have a filter of class A that is instantiated and called by the container in a normal fashion. Also assume that the A filter, upon some certain condition being met, creates and calls an instance of another filter of class B that is not used in the deployment descriptor.
Perhaps it is just me, but suddenly "The destroy() method is always a container callback" does not feel entirely true any more...


Exactly... I think the question is too confusing & ambiguous.

-- Srikanth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubts in HFSJ (Filters chapter)
 
Similar Threads
doFilter
Doubts in the answers of Filter chapter of HFSJ
about filter
HF: Filters and Wrappers question
Filter Question