• Post Reply Bookmark Topic Watch Topic
  • New Topic

doFilter

 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFSJ 1st edtion: Page 696 Question 1.
a. Which are true for filters.
Answers:
B) The destroy method is always container callback.
D) The only way to invoke filter is through a declaration in DD.
Answer B.D
One more option.
C) The doFilter method is always a container call back method.

My questions
a) What is a container callback method? Does this mean it can be invoked only by the container and cant be invoked via code. If that is the case then B is wrong.

And since the answer B is correct acc to HSFS why is option C incorrect?
One more question regarding option C. The doFilter method of which interface Filter or FilterChain?

Please reply
 
Felix Li
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a callback method means that the container will automatically call it within the lifecycle of a filter, which makes B true, since a container will call init(), doFilter() and destroy().

One more question regarding option C. The doFilter method of which interface Filter or FilterChain?


Exactly! That's what makes this question tricky I think. Because doFilter() can be called by FilterChain object, that makes it not "always a container call back method"

cheers
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!