Hello Friends,
I am confused with one question in the Head First Book (
Servlets and
JSP) about Filters (chapter 13 page 728).
"A filter can act on only the request or response object, not both." This question is not true.
Technically the answer is correct, it will compile and "work", but I can not imagine any case where the request and the
response filter will be the same class or can you give me an example?
The main different between request and response filter are the method call chain.doFilter(request, response).
The request filter calls the chain at the beginning and the response at the end within the doFilter method. Furthermore
the response filter uses a wrapped response object, otherwise we will not get the response back. So it depends
on the kind of filter how I will implement the filter class.
Thanks in advance
Holger