toltsch Posted October 12, 2006 Share Posted October 12, 2006 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 URLit works: http://localhost:9080/CWCollaborateAppWeb/cdc/images/cwilogo.jpg 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); exporter.exportReport(); I also added these lines to my web.xml file: <servlet><servlet-name>ImageServlet</servlet-name><servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class></servlet><servlet-mapping><servlet-name>ImageServlet</servlet-name><url-pattern>/servlet/image</url-pattern></servlet-mapping> Link to comment Share on other sites More sharing options...
lucianc Posted October 12, 2006 Share Posted October 12, 2006 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. HTH,Lucian Link to comment Share on other sites More sharing options...
toltsch Posted October 12, 2006 Author Share Posted October 12, 2006 I'm not sure about what you mean by your reply. Should I change exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); to exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/servlet/image?image="); My web app is named CWCollaborateAppWeb. The URL from the browser of the outputted report is : http://localhost:9080/CWCollaborateAppWeb/servlet/com.cwi.cdc.vendor.packslip.PackSlipServlet?action=packingslipform.jsp&divid=555&batchid=517&count=1 Link to comment Share on other sites More sharing options...
toltsch Posted October 13, 2006 Author Share Posted October 13, 2006 I got it to work! I had to change the from exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); to exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "http://localhost:9080/CWCollabAppWeb/servlet/net.sf.jasperreports.j2ee.servlets.ImageServlet?image="); 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