Olá amigos!
Estou utilizando a seguinte classe para gerar um relatório em pdf com jsf:
public static void imprimir(String relatorio, HashMap<String, Object> parametros, HttpServletResponse response, Connection conexao) {
try {
byte[] arquivo = new byte[0];
Class classpath = new Object().getClass();
URL url = classpath.getResource("/webponto/relatorios/" + relatorio + ".jasper");
JasperReport jasper = (JasperReport) JRLoader.loadObject(url);
JasperPrint print = JasperFillManager.fillReport(jasper, parametros, conexao);
arquivo = JasperExportManager.exportReportToPdf(print);
response.setContentType("application/pdf");
response.setContentLength(arquivo.length);
OutputStream saida = response.getOutputStream();
saida.write(arquivo, 0, arquivo.length);
saida.flush();
saida.close();
} catch (Exception ex) {
System.err.println("O arquivo não foi gerado corretamente!");
ex.printStackTrace();
}
}
Porém a variável url está ficando com valor null.
Como posso resolver isso?
Desde já agradeço!