please refer hfsj book 2nd edition page 715. it talks about compression filter and how to implement it. below is the basic structure the book shows
public void doFilter(request, response, chain) {
// this is where request handling would go
chain.doFilter(request, response);
// do compression logic here
}
further the book says that in the
servlet when we write something to response object it goes through the container straight to client and filter DOES NOT get shot in doing the compression logic. i couldnt understand this. i made a small
test program as shown below
in the above example the output we get is
before chain this is from servlet after chain. this means that after the servlet writes to response , the filter gets another shot and is able to write the output. so that means the as the book says the output DOES NOT goes to client. so that means the filter can do the compression logic right away after doFilter chain call. but turning few pages the book says we need to use wrapper and all that stuff. where i'm wrong. ?