Jump to content
Changes to the Jaspersoft community edition download ×

Please Help!!! Can't get images to display in HTML


Recommended Posts

Sorry for reposting this issue, but I'm really stuck.


I'm using the JRHtmlExporter to create an html report.


The report displays in the browser but the images are not displayed.


The image tag looks like this in the html:


img src="image?image=img_0_0_2"


When I use the isLazy attribute the image src is empty


img src=""


I'm using the java.net.URL in the report.


When I use the ireport tool and test using this URL

it works:




My code looks like this:


JRHtmlExporter exporter = new JRHtmlExporter();


HashMap imagesMap = new HashMap();


request.getSession().setAttribute("IMAGES_MAP", imagesMap);

request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print);

exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,"<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body>");

exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");

exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);

exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);




I also added these lines to my web.xml file:










Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The lazy flag only works for images having java.lang.String source expressions. For java.net.URL images, the image data is loaded at fill time and saved in the image renderer.


Regarding the non-laxy HTML image url, I see that you are using a relative URL for JRHtmlExporterParameter.IMAGES_URI. In this case, you should check that the context URL of the exported HTML matches the URL mapped to the image servlet.




Link to comment
Share on other sites

I'm not sure about what you mean by your reply.


Should I change


exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");




exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/servlet/image?image=");


My web app is named CWCollaborateAppWeb.


The URL from the browser of the outputted report is :



Link to comment
Share on other sites

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...