This is the following I created the report in jasperReport I created a parameter there, with that the data of this report it is getting from the bank (Mysql) and displaying /
But when I post to display on my JSF page the data is blank in a blank pdf format. Follow my code
In the apache server console, displays this message ...
Caused by: java.net.MalformedURLException
public RelatorioBean() {
this.context = FacesContext.getCurrentInstance();
this.response = (HttpServletResponse) context.getExternalContext().getResponse();
}
public void exporterPdf() {
stream = this.getClass().getResourceAsStream("/Ireport/ireport_1.jrxml");
Map<String,Object> params = new HashMap<String,Object>();
params.put("cpf_Funcionario",params);
params.put("invoice_logo",params);
baos = new ByteArrayOutputStream();
try {
JasperReport report = JasperCompileManager.compileReport(this.getClass().getResourceAsStream("/Ireport/ireport_1.jrxml" ));
JasperPrint print = JasperFillManager.fillReport(report,params, Conexao.getConexao());
JasperExportManager.exportReportToPdfStream(print, baos);
JasperViewer view = new JasperViewer(print,false);
view.setExtendedState(JasperViewer.MAXIMIZED_BOTH);
view.setVisible(true);
response.reset();
response.setContentType("application/pdf");
response.setContentLength(baos.size());
//attachment
response.setHeader("Content-disposition","inline;filename=ireport.pdf");
response.getOutputStream().write(baos.toByteArray());
response.getOutputStream().flush();
response.getOutputStream().close();
context.responseComplete();
} catch (JRException ex) {
Logger.getLogger(RelatorioBean.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, "Falha ao exportar: " + ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
} catch (IOException ex) {
Logger.getLogger(RelatorioBean.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, "Falha ao exportar: " + ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
}
I would like your advice, kindly !!