You can read in any file and encode it to jpeg and send it as a response.
Look up the Java Advanced Imaging API to find the JPEG Encoder/Decoder.  You
will also have to set your content type to "image/jpeg".  Here is a sample
function I use to send my generated map image to the client.

    private void sendImage(HttpServletResponse response, BufferedImage bi) {
        try {
            ServletOutputStream out = response.getOutputStream();
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
            encoder.encode(bi);
        } catch (IOException ioe) {
            servlet.log("DrawMapAction: IO Exception encoding JPEG to
ServletOutputStream.", ioe);
        }
    }

Then in my html, I make an image tag which points to my struts action such
as

<html:img page="/secure/map/draw.do?ForceRefresh=<%= (new
java.util.Date()).getTime() %>" border="0"/>

The force refresh is to make sure the client browser doesn't cache the
image.

http://java.sun.com/products/java-media/jai/

Hope this helps,
Graham



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 05, 2002 10:05 AM
To: [EMAIL PROTECTED]
Subject: Displaying a dynamically created Image.



How do I display a dynamically created Image with struts
without saving it to my local harddisc and link the image on it?
thanks matthias

----------------------------------------------------------------------------
----------------
Hanel Matthias
Fachinformatiker (Anwendungsentwicklung) in Ausbildung
Logistik World GmbH     Fon:    +49-841-9014-300
Marie-Curie-Strasse 6   Fax:    +49-841-9014-302
D- 85055 Ingolstadt     mailto:[EMAIL PROTECTED]
----------------------------------------------------------------------------
----------------


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to