Estoy intentando cargar un reporte generado con iReport, estoy utilizando el siguiente codigo:
Código PHP:
<%
try{
ResultSet rs = null;
Statement st = null;
String sql = null;
String driver = "com.mysql.jdbc.Driver";
String connectString = "jdbc:mysql://localhost:3306/test_dao";
String user = "root";
String password = "root";
Class.forName(driver);
Connection conn = DriverManager.getConnection(connectString, user, password);
System.out.println("********Compilamos rpt01.jrxml OK********");
System.setProperty(
"jasper.reports.compile.class.path",
application.getRealPath("/WEB-INF/lib/jasperreports-2.0.3") +
System.getProperty("path.separator") +
application.getRealPath("/WEB-INF/classes/")
);
System.out.println("*****Cargamos el jasperreports-2.0.3 OK*********");
System.setProperty("jasper.reports.compile.temp",application.getRealPath("/rpts/"));
JasperCompileManager.compileReportToFile(application.getRealPath("/rpts/rpt01.jrxml"));
System.out.println("******Fin de la Compilamos el archivos***********");
File reportFile = new File(application.getRealPath("/rpts/rpt01.jasper"));
Map parameters = new HashMap();
byte[] bytes =
JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,conn);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
System.out.println("jasperPDF OK..............");
///////////////////////////////////////////////////////////////
System.out.println("Fin del reporte pago_reporte_nomina.............");
}catch (JRException e){
System.out.println("Error:" +e.getMessage());
}catch (Exception e){
e.printStackTrace();
System.out.println("Error2:" +e.getMessage());
}