Hi Robin thx for you answer! I know this way to do it. The problem is that the guys here have written their own dispatcher servlet so that I can't access the picture that way. I also need to do a few SQL statements first so that I use a controller I wrote that collects all the data needed and then generates a bar chart.
Michael -----Ursprüngliche Nachricht----- Von: Robin Mannering [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 23. März 2005 12:43 An: Velocity Users List Betreff: RE: Embedding an temporary Picture into an Template Hi Michael, We embed images using servlets a fair bit and what we intend to do is this: In the JSP/VM page, have a standard HTML img tag as : <img src="servlet/GetImageServlet" alt="Server Side Image"> The servlet that is called from within the image tag then creates the image and streams it directly back using an OutputStream. Hope this helps Robin -----Original Message----- From: Michael Belz [mailto:[EMAIL PROTECTED] Sent: 23 March 2005 11:35 To: velocity-user@jakarta.apache.org Subject: Embedding an temporary Picture 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] ==================================================================== This e-mail and any attachments may be confidential and/or legally privileged. If you have received this e-mail and you are not a named addressee, please inform Landmark Information Group on 01491 413030 and then delete the e-mail from your system. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. This email and any attachments have been scanned for viruses and to the best of our knowledge are clean. To ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our servers. --------------------------------------------------------------------- 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]