Hi,
You are mising something here. You shouldn't mix anything.
The servlet should return only a html page that has an (static or dinamic)
image one it.
The browsers' job is to make another request to the server and get the
image.
So put in your servlet something like:
out.println("<img
src=\"http://www.somewhere/servlet/ImageGenerator?id=234\">");
Than in this ImageGenerator:
res.setHeader("pragma","no-cache");
res.setHeader("content-encoding","image/gif");
res.setContentType("image/gif");
GifEncoder encoder = new GifEncoder(image,out);
encoder.encode();
res.flushBuffer();
Hope this helps a little bit.
p.s. It can be done in one servlet too.
Best wishes,
Andras.
----- Original Message -----
From: Jaume <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 22, 2000 12:16 PM
Subject: How do you put a html page with a dynamic gif together?
> Hi
>
> How can I mix binary data (gif image) with the text data of a html page?
>
> I want to create a dynamic html page using servlet 2.2, well, I use the
> Acme package to import a gif image...
>
>
> As say in the api docs:
>
> "To send binary data in a MIME body response, use the
> ServletOutputStream returned by getOutputStream(). To send character
> data, use the PrintWriter object returned by getWriter(). To mix binary
> and text data, for example, to create a multipart response, use a
> ServletOutputStream and manage the character sections manually."
>
>
> And why this code doesn't run :-?
>
>
> This is the important part of the code.. I have not put all the code,
> only the important one...
>
>
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
>
> ServletOutputStream out = res.getOutputStream();
> HttpSession session = req.getSession(true);
> file://part1
> res.setHeader("pragma","no-cache");
> res.setHeader("content-encoding","text/html");
> res.setContentType("text/html");
> out.println("<HTML><HEAD><TITLE>Cuantos Somos _ Somos unos
> cuantos</TITLE></HEAD><BODY>");
> out.println("<FONT FACE=Tahoma,Arial,Helvetiva>Actualmente hay
> "+count+" usuarios en esta p�gina");
> out.println("<CENTER><H3>Gr�ficamente</H3></CENTER>");
> res.flushBuffer();
> file://part2
> res.setHeader("pragma","no-cache");
> res.setHeader("content-encoding","image/gif");
> res.setContentType("image/gif");
> GifEncoder encoder = new GifEncoder(image,out);
> encoder.encode();
> res.flushBuffer();
> file://part3
> res.setHeader("pragma","no-cache");
> res.setHeader("content-encoding","text/html");
> res.setContentType("text/html");
> log("Encoding Type: "+res.getCharacterEncoding());
> out.println("<HR></BODY></HTML>");
> res.flushBuffer();
> }
>
> }
>
> If I put part2 only in the doget method it run, the same with part1 and
> part3, but all mix not :-?
>
> How do you put a html page with a dynamic gif together?
>
>
___________________________________________________________________________
> 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
___________________________________________________________________________
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