Filters in
servlet api 2.3 performs pre-processing or post-processing task prior or after the associated servlet is invoked.
so the filter is positioned between the client and the servlet. If its a post-procesing filter( for eg XSL formatting etc ), it also gets invoked prior to the servlet invocation but does nothing since the code in doFilter method is just meant for tweaking the output.
Does this mean that the programmer should take care that the doFilter method code should not cause any issue while the filter acts on the incoming request ?
And doesnt this cause unnecessary filter invocation during incoming request while its only needed during outcoming response. Doesnt this cause a performance issue?
If this is how it works and i understand correctly, then there are two issues,
1) coder has to take precaution in the doFilter method.
2) performance issues due to unnecessary invocation of filter.
And if a filter is meant only for pre-processing or post-processing, why doesnt the deployment descriptor give an indicator so that the container can take care of the rest and avoid the above drawbacks.
Let me know if anyone have come across this or my interpretation is incorrect.