Hi,
I'm referring to this posting:
>
> I'm using JavaMail to read a MimeMessage. One Part of the mail contains an
> image (image/jpeg). I can create an InputStream for this image. But if I
> simply write the bytes to the ServletOutputStream it'll only appear a
> broken-image symbol.
>
> How am I to implement writeImageBytes()? Currently I'm using:
>
> response.setContentType("image/jpeg");
> ServletOutputStream sos = response.getOutputStream();
>
> // Part pa is the Part of the mail which contains the image
> InputStream is = pa.getInputStream();
> int c;
> while ((c = is.read()) != -1) {
> sos.print(c);
> }
>
> What is wrong with that? I can't imagine that it's so difficult...
>
> thx in advance
>
> Christian
For that purpose i use :
response.setContentType(msg.getContentType());
OutputStream os = response.getOutputStream();
InputStream is=new
BufferedInputStream(((Part)attachments.elementAt(id)).getInputStream());
int b;
while((b=is.read())!=-1){os.write(b);}
os.flush();
os.close();
is.close();
It works fine for me. Maybe its about closing the stream or not flushing it
beforehand?
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html