File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problem with a filter to alter a gif in the response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem with a filter to alter a gif in the response " Watch "Problem with a filter to alter a gif in the response " New topic
Author

Problem with a filter to alter a gif in the response

G Roberts
Greenhorn

Joined: Nov 03, 2005
Posts: 2
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.

Any ideas? It must be something pretty stupid!

Thanks in advance.

Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410




Are you trying mix HTML with the binary data from the image?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
G Roberts
Greenhorn

Joined: Nov 03, 2005
Posts: 2
Hi,

Sorry, my posting was not as clear as it should have been. I have this problem with an image modifying servlet, but I also have the same symptom with the much simpler PrePostFilter example.

So, this question only concerns outputting html. I also forgot to say that the html appended after the original output never appears.

Any more ideas welcome because this one is driving me nuts.

G.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with a filter to alter a gif in the response