Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF's Chapter 13 Ques. 5

 
Amitkumar Dhama
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
In the HF's chapter - 13 coffee cram exam

Q.no.-5 Which about filter's are true??

in the book option 'E' is given incorrect

"A filter's doFilter() method must call doFilter() on the input FilterChain object in order to ensure that all filters have a chance to execute"

The explanation given in the book is,

"Calling doFilter() is not necessary if a filter wishes to block furthur request processing "

in my openion Both 'E' and the explanation are correct coz....

"It is not necessary to call FilterChain's doFilter(), but to ensure that all filters have a chance to execute it must be called"

and that's what is given in the explanation, explanation is not proving 'E' is incorrect. If 'E' is incorrect then there must be some other way to do the same thing..

tell me if i am wrong

Thanking in advance.....
 
Pranav Shukla
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The filter is not required to call the next filter in the chain by invoking doFilter method on the filter chain.

If you don't want to invoke the next filter using chain.doFilter(request, response) you can just send the response back to the client and commit the response. You might want to do this if you are implementing a filter which checks for security, if you find that the request should not be forwarded to the actual target (may be a servlet) then you won't call doFilter and just send an HTTP error code back to the client (HTTP unauthorized error code 403).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic