That worked great. Thanks for the info. Also thanks to the others who
offered different flavors of the same idea.
Kenny
----- Original Message -----
From: "Richard Yee" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 30, 2002 2:38 PM
Subject: Re: Mixing HTML and JPEG image on one output page
> Kenny,
> Use two servlets or a JSP and a servlet. One jsp/Servlet outputs the HTML
> page with an img tag that has the src attribute that specifies a URL to a
> second servlet that produces the JPEG image.
>
> -Richard
>
>
> At 02:27 PM 9/30/2002 -0500, you wrote:
> >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
___________________________________________________________________________
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