Olá alguém saberia me dizer como eu posso fazer para exibir um relatório pdf utilizando o jasper reports em uma aplicação web ?
Obrigado.
public String printInputFinalizationReport() {
try {
ReportService reportService = BaseBPRMBusinessServiceLocator.getInstance().obtainReportService();
ArrayList reportData = reportService.printInputFinalizationReport(new RequestContext(), getProduct(), Integer.parseInt(getMonth()), Integer.parseInt(getYear()));
//passes the date selected to the report
HashMap reportParameters = new HashMap();
reportParameters.put("Month", getMonthDescription(Integer.parseInt(getMonth())));
reportParameters.put("Year", year);
printReport(reportData, reportParameters, INPUT_FINALIZATION_REPORT);
addInfoMessage(null, "report.success", null);
}
catch (NoDataFoundException e) {
addErrorMessage(null, "report.error.noData", null);
log.info("NoDataFoundException on ReportBackingBean.printPendencesReport:", e);
}
catch (Exception e) {
addErrorMessage(null, "report.error.general", null);
log.info("Error on ReportBackingBean.printInputFinalizationReport:", e);
}
return null;
}
private void printReport(ArrayList reportVO, HashMap hm, String jasperFilename) throws Exception {
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(reportVO);
JasperRunManager.runReportToPdfStream(
ReportServiceBean.class.getResourceAsStream(REPORTS_ROOT_FOLDER+jasperFilename),
((HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse()).getOutputStream(), hm,
dataSource);
FacesContext.getCurrentInstance().responseComplete();
}
Deste modo não está funcionando.