Michael -

What you're trying to do...can't be done. ;-)

HTTP doesn't work that way. 

http://server/mypage.html -> is one server request which returns HTML.
<img> tags in the HTML make -separate- sever requests for each image.

Instead of .html -> .vm requests just means that the template will be
parsed before being sent -AS HTML- to the client. Embedded IMG tags
still make a -separate- request to the server.

So this isn't a Velocity problem per se, it's how http requests work.
;-)

Cheers,
Tim









> -----Original Message-----
> From: Michael Belz [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, March 23, 2005 4:29 AM
> To: velocity-user@jakarta.apache.org
> Subject: Embedding a Servletgenerated Graphic into an Template
> 
> 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