This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to Get JasperReport from JSP  RSS feed

 
Asit Patadia
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am a novice of JasperReports. It is an open source reporting engine.
I have got a problem. I am unable to generate a report through a JSP.
Following is a code to generate the report:
_______________________________________________________________________

<%@ page import="net.sf.jasperreports.engine.design.JasperDesign" %>
<%@ page import="net.sf.jasperreports.engine.JasperExportManager" %>
<%@ page import="net.sf.jasperreports.engine.JasperManager" %>
<%@ page import="net.sf.jasperreports.engine.JRException" %>
<%@ page import="net.sf.jasperreports.engine.JasperReport" %>
<%@ page import="net.sf.jasperreports.engine.JasperPrint" %>
<%@ page import="net.sf.jasperreports.engine.export.JRXlsExporter" %>
<%@ page import="net.sf.jasperreports.engine.export.JRXlsExporterParameter" %>
<%@ page import="net.sf.jasperreports.engine.JRExporterParameter" %>
<%@ page import="net.sf.jasperreports.engine.JRException" %>


<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>

<%

Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;

try {

Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc ostgresql://localhost:5432/firstdb","asitp","luvasit");
}
catch(SQLException se) {
out.println("SQL Exception");
se.printStackTrace();
}
%>
<br>
<%

try {
java.util.Date d1 = new java.util.Date();
long l1 = d1.getTime();
out.println("Started generating report.");
JasperDesign design = JasperManager.loadXmlDesign("C:/Tomcat 4.1/webapps/jaspersample/jsp/friends.jrxml");
JasperReport report = JasperManager.compileReport(design);
Map params = new java.util.HashMap();
JasperPrint print = JasperManager.fillReport(report, params, conn);
JasperExportManager.exportReportToPdfFile(print,"C:/Tomcat 4.1/webapps/jaspersample/Reports/aztec_asit.pdf");
out.println("Report generated into PDF Format.");
java.util.Date d2 = new java.util.Date();
long l2 = d2.getTime();
%> <br> <%
out.println("Time take to generate this report is : " + (l2 - l1));
}
catch (JRException jre) {
%> <br> <%
out.println("JRException Caught.");
%> <br> <%
out.println("JR Error: " + jre.toString());
jre.printStackTrace();
}

try {
if (rs != null)
rs.close();
if (ps != null)
ps.close();
if (conn != null)
conn.close();
}
catch (SQLException e) {
out.println("SQL Error closing");
}

%>
________________________________________________________________________

I am getting following error:


Started generating report.
JRException Caught.
JR Error: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: See error messages above.


Please help me out...

Thanx & Regards,
Asit Patadia.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!