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);
//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();
//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();
//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

Reply via email to