File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubts in HFSJ (Filters chapter)

 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 389
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic