"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.....
SCJP 1.4, SCWCD 1.4, M.Tech(CSE)
posted 10 years ago
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).