Image Servlet Not Rendering

Hello,

I've created a portlet using Liferay.  I believe I have this set correctly but I can not get the images to display.  I'm new to Java so I'm trying to determine the best way to debug this.  My code is here:

                JRHtmlExporter exporter = new JRHtmlExporter();
 
		request.getPortletSession().setAttribute(
				ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,
				printObject);
		exporter.setParameter(JRExporterParameter.JASPER_PRINT, printObject);
		exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER,	outputBuffer);
		exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, new HashMap());
		exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../servlets/image?image=");
		exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, java.lang.Boolean.FALSE);
		exporter.setParameter(JRHtmlExporterParameter.IGNORE_PAGE_MARGINS, java.lang.Boolean.TRUE);
 
		exporter.exportReport();
 
And I have this code in my web.xml
 
	<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>/servlets/image</url-pattern>
	</servlet-mapping>
 
Everywhere I read makes me believe I have this right, but I am getting nothing in the HTML version.  The PDF and XLS versions of the reports all show the graphics and graphs.  Any clues on how to debug this or troubleshoot this and track it down?
 
Thanks,
George
gstafford's picture
Joined: Oct 9 2012 - 2:18pm
Last seen: 10 years 2 months ago

2 Answers:

ImageServlet/image

request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");

see for example http://community.jaspersoft.com/questions/801752/html-export-image-impos...

sanbez's picture
5830
Joined: Jan 11 2011 - 2:06am
Last seen: 2 years 5 months ago

So I made the adjustments you recommended - I apologize for taking so long, busy week. When I do this the code in the browser renders as http://xxxxxxx/group/guest/image?image=px which returns a 404. I've adjusted the link several different ways including http://xxxxxx/image?image=px and I get a 404 with all of them. Any other thoughts?

gstafford - 10 years 2 months ago

I am not sure I get your image displaying issue in the right way, but I think you can read this blog, most of it talking about the imaging issue in liferay.smiley

http://longgoldenears.blogspot.de/2008/03/portaldelegateservlet-servlet-...

amywhite989's picture
Joined: Feb 7 2014 - 6:25pm
Last seen: 8 years 10 months ago
Feedback