i'm using the jasperreports-plugin for struts2.
I've created some reports using iReport. When i export a report in any format other than HTML, the report is correctly generated. But when i try to export it in HTML, the browser doesn't find any image.
For reports without charts it isn't a big problem, in them a "px" image is missing. Since it is a static image it is not a great problem, i found a quick workaround and maybe later i will try to force the export parameters to not use images to fill spaces.
My real problem is when i try to generate reports containing charts. The browser doesn't find any of the generated images.
I would like to know what is going wrong, or at least if and where the generated images are stored in a temp folder.
Here is the action definition in my struts.xml:
<package name="jasperreport" namespace="/reports" extends="jasperreports-default">
<action name="myJasperTest" class="[...]JasperReportAction" method="getTestReport">
<result name="success" type="jasper" >
<param name="location">/WEB-INF/jasper/${outFile}</param>
<param name="connection">sqlConnection</param>
<param name="reportParameters">reportParams</param>
<param name="format">${format}</param>
</result>
</action>
</package>
And my Action JasperReportAction.java:
public class JasperReportAction extends ActionSupport {
//various initialization..getter, setters..
public String getTestReport() {
try {
JasperCompileManager.compileReportToFile(sourceFile, outFile);
//test to see a generated file
JasperReport report = JasperCompileManager.compileReport(sourceFile);
JasperPrint print = JasperFillManager.fillReport(report, new HashMap<String, Object>(), sqlConnection);
JasperExportManager.exportReportToHtmlFile(print, "/home/user/output.html");
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}
return SUCCESS;
}
}
I also have added an action in my struts.xml to avoid exceptions for action not found when the generated report requests url for images like "/images/px" without exension:
<package name="px" namespace="/images" extends="struts-default">
<action name="*">
<result>/images/{1}</result>
</action>
</package>
At least with this i get a "404 - not found" instead of an action not found exception. The last code rows in the JasperReportAction class creates an HTML file with an associated folder with the generated charts, and all is displayed as it should.
I hope someone can tell me where i can find the generated charts, or if i can specify a name for them. Any help would be appreciated :)
thanks in advance