Java Reference
In-Depth Information
If the report we are exporting contains images, then there are a couple of extra steps
we need to take to make sure the images are displayed correctly in the browser. We
must attach the JasperPrint instance to the HTTP session. The session attribute
name is defined in the DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE constant
defined in net.sf.jasperreports.j2ee.servlets.ImageServlet .
We also need to set the JRHtmlExporterParameter.IMAGES_URI parameter as an
instance of JRHtmlExporter . Its corresponding value must be a string indicating
the location of the images. In practice, this value is almost always set to the URL
mapped to the net.sf.jasperreports.j2ee.servlets.ImageServlet included
with JasperReports. In our example, we set its value to "image?image=" , which is a
typical value. Of course, the ImageServlet must be included in web.xml for reports
with images to render properly. The web.xml corresponding to the previous servlet
deployment is as follows:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>webreport</servlet-name>
<servlet-class>
net.ensode.jasperbook.HtmlReportServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>
net.sf.jasperreports.j2ee.servlets.ImageServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>webreport</servlet-name>
<url-pattern>/webreport</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/image</url-pattern>
</servlet-mapping>
</web-app>
 
Search WWH ::




Custom Search