Hi,

since your code snippet works for 1 image, then you can refer to
this URL from another veloctity generated HTML pages using the
<img src=...> element. The browser will then open additional
connections to your server and retrieve the image(s).

You may have the problem that HTML generating servlet also
generates the image. Here you can store the image in the servlet
application context or in some other static caching tool, this
allows you to retrieve the data in separate http connections
(from a properly configured servlet).

If you only want to embed small graphics in a page, the embedded
data URL scheme: http://www.faqs.org/rfcs/rfc2397.html
and http://www.elf.org/essay/inline-image.html may be a solution.
Note the restriction to about 1024 bytes.

Another solution, but with higher overhead, would be to render
the whole generated HTML page (with embeded images) into a GIF/PNG
with something like FOP (see xml.apache.org), and send only this
super-image to the browser.

Within an email, you can use a multi-part message to add any size
images to be displayed inline in an HTML-coded email. With plain
HTML browsers this is not availabe. Here you can only use the
img-tag or JavaScript to feed in the image into the page. If all
is to be done within one HTTP connection, you might consider
using the HTTP keep-alive feature.

You seem to understand the problem, but are asking if anyone has
a realy bright solution. If something is not clear, or your need
some pointers, or you're sure that there might be other solutions,
you can re-ask on this thread.

Cheers,
:) Christoph Reck


Michael Belz wrote:
Hi,

I'm trying to put a graphic into an Velocity Template (vm).
The problem is that the servelt generated graphic should not be physically saved to an temporary folder on the server. It's an encoded jpeg stored in a bytearray. When I use the servlet path
at an 'img src'-tag the graphic is shown. But I don't have this
option here. I already tried to add the bytearray to the context
by using the method put() but then I only get the hash of the bytearray (because of the toString() method I guess).


Here's my code:
--------------------------------------------------
        public void perform(Context context, HttpServletRequest request,
            HttpServletResponse response, Properties initProps,
Properties sessionProps) throws IOException {
                
        super.perform(context, request, response);
        HttpSession session =request.getSession();
                

                double[] data = new double[7];
                for (int i = 0; i < data.length; i++){
                        data[i] = Math.random() * 150000;
                }
                
                BarChart chart = new BarChart(600,1999,data);


response.setContentType("image/jpeg");
String strFileName = "test.jpg";
OutputStream imageout = response.getOutputStream(); imageout.write(chart.getJpegByteArray());
//context.put("trigger",chart.getJpegByteArray()); //
doesn't Work
}
----------------------------------------------


When I put the Image directly onto the response outputstream, the
picture is shown.
But ONLY the picture. I need to add some additional HTML Code around it.
Like I said
context.put() doesn't work.

Can anybody help me out?



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




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



Reply via email to