I think what you want is actually two completely separate servlets. One will create the graph, just like you've already started work on.
The second would write the HTML page that displays the graph. So, a browser URL would refer you the HTML generating servlet. In the generated HTML page would be the <IMG> tag, with it's HREF parameter refering to your graphing servlet. Paul -----Original Message----- From: Kenny G. Dubuisson, Jr. [mailto:[EMAIL PROTECTED]] Sent: September 30, 2002 3:27 PM To: [EMAIL PROTECTED] Subject: Mixing HTML and JPEG image on one output page I'm trying to write a servlet that draws a chart and put's some HTML info about the chart on a page. For a test, I got a servlet to draw a blue rectangle (proving my graphics and JPEG encoding worked) in my browser. The problem I'm having is that I can't seem to add HTML to the page; it only draws the rectangle when I send the graphics as a single JPEG image. Does anyone know how to mix an embedded JPEG image and regular HTML? I've attached my little test servlet below for reference. Thanks, Kenny import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.awt.*; import java.awt.image.*; import com.sun.image.codec.jpeg.*; public class GraphicsTest extends HttpServlet { private static final int WIDTH = 650; private static final int HEIGHT = 650; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // open the output and set the type to JPEG ServletOutputStream out = response.getOutputStream(); response.setContentType("image/jpeg"); // create a blank image BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setColor(Color.blue); g2.fillRect(0,0,WIDTH,HEIGHT); // encode the output to JPEG JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); encoder.encode(image); // send the output out out.flush(); out.close(); } } ___________________________________________________________________________ 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
