I'm using JSF and Primefaces, and I need to download a PDF that I generated with iReports and Jasper.
I save the PDF this way, in this path:
String caminhoReports = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/WEB-INF/reports");
File pdf = new File(caminhoReports+"/relatorio2.pdf");
pdf.createNewFile();
FileOutputStream arquivo = new FileOutputStream(pdf);
JasperExportManager.exportReportToPdfStream(impressoraJasper, arquivo);
It is saved in this directory:
D:\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4\wtpwebapps\monitorias\WEB-INF\reports\relatorio2.pdf
How do I put a button to download this report? I tried to use the download component of primefaces but it did not give, when I pass this path it says that the resource is not valid.