Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JasperReports: Calling report from servlet [duplicate]

I'm new to JasperReports and dont know how to call jasper file from servlet. My report contains the pie chart.

like image 380
deven Avatar asked Mar 08 '10 05:03

deven


1 Answers

You can prepare the Jasper file and stream it to the client.

bytes[] byteStream = JasperRunManager.runReportToPdf("myJasperReport.jasper",paramMap,databaseConn);

OutputStream outStream = servletResponse.getOutputStream();
response.setHeader("Content-Disposition","inline, filename=myReport.pdf");
response.setContentType("application/pdf");
response.setContentLength(byteStream.length);
outStream.write(bytes,0,bytes.length);
like image 53
medopal Avatar answered Nov 15 '22 08:11

medopal