I want to intercept a gif on its way from a servlet to the browser, so I've got a Filter working, which is called, and which successfully draws on the image and sends it to the response output stream, except that the end of the gif is corrupt. The filter can write the gif out to the filesystem without corrupting it so I know the problem is with my misunderstanding of Filters.
I can see the same thing happening in the example below. It succesfully adds "<HR>PRE<HR>" to the finished page, but for then fails to send the last 11 characters of the file being filtered. It's as if the response stays the same length even though the filter adds stuff to it.