gerson2002 Posted November 15, 2011 Share Posted November 15, 2011 I already created the report with ireport but now i want read that report in my jsp app i found this old example is using jasperreport 2.0.4 this my code <%@page import="net.sf.jasperreports.engine.*" %> <%@page import="java.util.*" %> <%@page import="java.io.*" %> <%@page import="java.sql.*" %> <% Connection conexion ; Class.forName("org.postgresql.Driver").newInstance(); conexion = DriverManager.getConnection("jdbc:postgresql://localhost:5432/antigua","postgres","grupo02antigua"); File reportFile = new File(application.getRealPath("Empleados.jasper")); Map parameters = new HashMap(); parameters.put("nombrepara", "valorpara"); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters,conexion); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(bytes,0,bytes.length); outputStream.flush(); outputStream.close();%> but is not working i already tryed File reportFile = new File(application.getRealPath("Empleados.jrxml")); and still doesnt work so any idea where i could find a exmaple to do this? any example to read reports in jsp. Thx Link to comment Share on other sites More sharing options...
satyadoorva Posted November 15, 2011 Share Posted November 15, 2011 I use the following code to generate PDF successfullyCode:<% Connection con=null; Mydao ad = new Mydao(); con = ad.getConnection(); Map parameters = new HashMap(); parameters.put("param1", "PH2011-001"); JasperReport report = JasperCompileManager.compileReport("demo.jrxml"); JasperPrint print = JasperFillManager.fillReport(report, parameters, con); String destFile = "NAME OF PDF FILE"; JasperExportManager.exportReportToPdfFile(print,destFile); out.println("PDF created ");%><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><strong class="highlight">JSP</strong> Page</title> </head> <body> <h1>Hello World!</h1> </body> Link to comment Share on other sites More sharing options...
gerson2002 Posted November 15, 2011 Author Share Posted November 15, 2011 nop is not working Empleados.jrxml (The system cannot find the file specified) I have my empleados.jrxml file in the same directory with my jsp page Link to comment Share on other sites More sharing options...
prabhakaranv1991 Posted November 15, 2013 Share Posted November 15, 2013 plz give full flow Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now