Is that
Java code in a
JSP? (an assumption made because you posted this in the JSP forum)
If so, move it to a
servlet. Foremost, Java code has no place in a JSP. Secondly, JSP is made for rendering text response, not binary data. The JSP may be adding extraneous characters that are screwing up your data stream. Please read
this article for more information