Hi DC,
try this:
ServletOutputStream sos = res.getOutputStream();
res.setContentType("image/png");
FileInputStream in = new FileInputStream("chart.png");
//Read file
//While not EOF sos.write(in);

Eseentially, you open a servlet outputstream, read the bin file from the
FileInputStream and write the FileInputStream to the servlet output stream.

Hope this helps,
Cheers ..
Yogesh

Consultant,
e-Services, Citibank,
New York, NY 10022
Tel (W) 212 559 3087
    (R) 201 533 0490



Dominique Chaniat <[EMAIL PROTECTED]> wrote:
Hello

I am writting a servlet, and I Have an image file (as gif or png) under
my filesystem.

I want read this binary file, and send to the web browser.

When I read this image file with the followed code, I don't receive it
inside my browser.
                       response.setContentType("image/png");
                      PrintWriter out = new
PrintWriter(response.getOutputStream());
                       FileInputStream in = new
FileInputStream("chart.png");
                       byte b;

                       while ( in.available() > 0) {
                         out.print(in.read());
                       }

                       in.close();


Do you have an idea about it

Thank in advance

> ---------------------------------------------
>       Attachment: chaniat.vcf
>       MIME Type: text/x-vcard
> ---------------------------------------------

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

___________________________________________________________________________
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

Reply via email to