Re: Insert PNG File from Servlet no go

Dmitry Skavish <[email protected]> Thu, 23 Jan 2003 17:19:07 -0500
Newsgroups gmane.comp.java.jgenerator.devel
Organization JZox, Inc.
Message-ID <[email protected]>
William,

> Now I am simply using the PrintWriter to write out png data, and the
> content type has been set to image/png.

You cannot use PrintWriter to send binary data. Use something like this:

         res.setContentLength(<size of the binary stream>);
         res.setContentType("image/png");

         ServletOutputStream sos = res.getOutputStream();
         try {
             sos.write(<byte buffer>, <buffer offset>, <buffer size>);
         } finally {
             sos.close();
         }

-- 
Dmitry Skavish
-----------------------
Boston, MA, USA
tel. +1 781 910-3810
http://www.jzox.com
http://www.flashgap.com




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com