Once filter2 is done with writing, the control returns to the calling filter1, which already has access to the Wrapped response object. The important aspect is that, the final response has not yet been sent to the client. It is still in the container, safely tucked inside the wrapped response object. Filter1, which has this response object, can do whatever it wants to do with it and then send it to the client.
There is nothing like Request Filter/response Filter...
there are only Filters....that act on request object before it is processed and response before it is sent back to client..
Code prior to chain.doFilter()
this code generally contains what we want to do with the request..any manipulations before it is processed
This calls takes the flow to the actual resource requested(servlet...)
performs the actual logic
And now the flow comes back to the code we might have put after
chain.doFilter() to manipulate the response using any wrapper object..
Response goes to client
I havent mentioned here multiple filter/Request or Response Wrapper...
But..say there is only 1 filter
the req and wrapped_resp are sent to the servlet after calling
now after the servlet is done implementing its logic does the control come back to filter..so that the code written after chain.doFilter could be executed.. ?? and if it does..then what purpose is served by using wraped response instead of direct response object ?? :roll:
Filtering the Servlet Response Object
You can use filters to post-process the output of a servlet by appending data to the output generated by the servlet. However, in order to capture the output of the servlet, you must create a wrapper for the response. (You cannot use the original response object, because the output buffer of the servlet is automatically flushed and sent to the client when the servlet completes executing and before control is returned to the last filter in the chain.) When you create such a wrapper, WebLogic Server must manipulate an additional copy of the output in memory, which can degrade performance.
now after the servlet is done implementing its logic does the control come back to filter..so that the code written after chain.doFilter could be executed.. ??
yes....the flow does go through .....
and if it does..then what purpose is served by using wraped response instead of direct response object ??
Your last post ....addresses this point...for the need for a response wrapper
[ January 08, 2007: Message edited by: A Kumar ]