Jump to content
Changes to the Jaspersoft community edition download ×

integrating images in jasper

2005 IR Help

Recommended Posts

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();





OutputStream ouputStream = response.getOutputStream();

ouputStream.write(bytes, 0, bytes.length);




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









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.




<field name="Path" class="java.lang.String"/>


<imageExpression class="java.awt.Image"><![CDATA[((Scriptlet)$P{REPORT_SCRIPTLET}).getImageFromPath($F{Path})]]></imageExpression> </image>





public Image getImageFromPath(String path) {

Image image = Toolkit.getDefaultToolkit().createImage(path);

MediaTracker tracker = new MediaTracker(new Panel());

tracker.addImage(image, 0);





catch (Exception e)





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

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...