You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Stephan Wiesner <wi...@werum.de> on 2001/07/30 18:02:57 UTC

Thanks (Re: Binary encoded String to original format, displayed in Browser)

Yeah, knew there was such a little trick.
Thanks a lot, works fine now.


Stephan

----- Original Message -----
From: "William Brogden" <wb...@bga.com>
To: <so...@xml.apache.org>
Sent: Monday, July 30, 2001 5:52 PM
Subject: Re: Binary encoded String to original format, displayed in Browser


>
>
> Stephan Wiesner wrote:
> >
> > I have a PDF on the server. I read it into a Base64 encoded String and
send
> > it with SOAP to the client.
> > The client determines the MimeType and writes it to a file.
> > no problem.
> > I, however, I want to give the file to a client, via a servlet, it get
> > changed and will not display.
> > The problem is, that I have a encoded String and a PrintWriter from the
> > Servlet. Seems, this PrintWriter changes the byte[] in some way while
> > sending it.
> > The resulting PDF has the original size and displays fine, except that
it is
> > empty.
> >
>
> You can't output binary data with a PrintWriter - it tries to do
> UNICODE translations. You have to use a ServletOutputStream from
> the response getOutputStream method.
>
> Be sure to set the Content-type and Content-length
>
> --
> WBB - wbrogden@lanw.com
> Java Cert mock exams http://www.lanw.com/java/javacert/
> Author of Java Developer's Guide to Servlets and JSP
> ISBN 0-7821-2809-2