That's the reason you must provide your own ServeltOutputStream to the filter chain. Anything the filter chain does on the outputstream will only be send to the client if your filter was able to commit:
Code:
- User do a query
- Filter stores the ServletOutputStream to a local variable
- Filter Create a memory based ServletOutputStream
- Filter call filterchain providing the memory based ServletOutputStream
- filerchain do various thing that end in various outputs
- Filter tries to commit
- if commit success, Filter copy the memory based ServletOutputStream to the locally saved ServletOutputStream
- if commit fail, send a redirect using the locally saved ServletOutputStream, don't care about what's in the memory based ServletOutputStream
- Returns