Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jasper Report blank

 
Sherryl Philip
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following JSP page where I'm trying to view a report which is generated using the iReport tool. But when I try to generate the Report, the Report turns up with the template and it also fetches the number of records, but the records are not seen on the Report. Anybody knows why is this so??
Can anybody help me out?
I'm stuck up here!!!

the Following is the code written for it :

<%@ page errorPage="error.jsp" import="net.sf.jasperreports.engine.*,net.sf.jasperreports.engine.util.*,net.sf.jasperreports.engine.export.*,
java.util.Map,java.util.HashMap,java.sql.*,java.io.File,java.io.PrintWriter,oracle.jdbc.driver.OracleDriver"%>


<%
Connection conn = null;
String driver = "oracle.jdbc.driver.OracleDriver";
String hostName = "....";
String user = "abcde";
String password = "abcde";


File reportFile = new File(application.getRealPath("/reports/report.jasper"));

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

Map parameters = new HashMap();
parameters.put("ReportTitle", "Address Report");
parameters.put("BaseDir", reportFile.getParentFile());


try{
Class.forName(driver);
conn = DriverManager.getConnection(hostName, user, password);

JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport,parameters,conn);

/*JasperPrint jasperPrint =
JasperFillManager.fillReport(
jasperReport,
parameters,
dataSource);*/

JRHtmlExporter exporter = new JRHtmlExporter();

StringBuffer sbuffer = new StringBuffer();
Map imagesMap = new HashMap();
session.setAttribute("IMAGES_MAP", imagesMap);
System.out.println("before exporter ");
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
System.out.println("JASPER_PRINT ");
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
System.out.println("OUTPUT_WRITER ");
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image.jsp?image=");
exporter.exportReport();
}catch(Exception e){
System.out.println(e.getMessage());
}

%>


Please do tell me where I'm wrong

thanks inadvance

Sherryl
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic