Reputation: 617
I am try to show an pdf in jsp page without saving this in the hard disk. I was able to generate a pdf and I tested it by saving it in hard disk. I am using DynamicJasper as reporting engine.
Here is my strut.xml for dynamic-jasper:
<action name="myJasperTest" class="com.via.qcm.view.JasperAction">
<result name="success" type="dynamic-jasper">
<param name="dynamicReport">DynamicReport</param>
<param name="layoutManager">classic</param>
<param name="parameters">dynamicReportDs</param>
<param name="documentName">report</param>
<param name="contentDisposition">application/download</param>
<param name="format">PDF</param>
</result>
I am generating pdf and saving it in ByteArrayOutputStream()
.
baos = new ByteArrayOutputStream();
//export to pdf
Exporter.exportToPdf(jp, baos);
Now my question is how to show this "baos" in webpage as pdf?
Upvotes: 2
Views: 630
Reputation: 50203
There are two problems:
DynamicReport
object, not an Byte Array
;lowercase
letter:In Struts.xml
<param name="dynamicReport">dynamicReport</param>
In the Action
public DynamicReport getDynamicReport(){
DynamicReport dynamicReport = null;
// do all your stuff
return dynamicReport;
}
Upvotes: 1