2005 IR Help Posted August 27, 2006 Share Posted August 27, 2006 By: odc - sameena integrating images in jasper 2004-10-20 04:01 i wish to display in a report a record from a table that has a mediumblob object (eg : image) field in it. i am exporting the data as bytearray.. to display the report on the browser as pdf/html file. if i dont include the mediumblob field in my report the report works properly. otherwise an exception is thrown : java.lang.IllegalStateException: getOutputStream() has already been called for this response my jsp code is : byte bytes[]=Reports.Basic_Report.ExportVerticalReportToPdf(); response.setContentType("application/pdf"); response.setContentLength(bytes.length); OutputStream ouputStream = response.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); outputStream.flush(); outputStream.close(); can anyone tell me is there any other way followed to handle images inside jasper separately. any suggestions for this problem will be appreciated. if possible pls try to include the code. By: macoute - macoute RE: integrating images in jasper 2004-10-20 05:24 In my reporting solution, my datasource have a field with a image path. I use scriptlet in order to transform jpeg file to java.awt.image. Try to use this solution to convert your bytearray. By: odc - sameena RE: integrating images in jasper 2004-10-20 21:29 hi macoute how can this be done.using jfreecharts? or u r talking abt any other way of accomplishing this. can u be a little more clear thks. By: macoute - macoute RE: integrating images in jasper 2004-10-21 00:22 Hereafter, you can find the template with the call to Scriptlet, and the Scriptlet method who transform jpeg file to java.awt.Image. Report.jrxml: <field name="Path" class="java.lang.String"/> <image> <imageExpression class="java.awt.Image"><![CDATA[((Scriptlet)$P{REPORT_SCRIPTLET}).getImageFromPath($F{Path})]]></imageExpression> </image> Scriptlet.java: public Image getImageFromPath(String path) { Image image = Toolkit.getDefaultToolkit().createImage(path); MediaTracker tracker = new MediaTracker(new Panel()); tracker.addImage(image, 0); try { tracker.waitForID(0); } catch (Exception e) { e.printStackTrace(); } return image; } By: odc - sameena RE: integrating images in jasper 2004-10-22 02:09 got it thks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now