angopal Posted June 28, 2007 Share Posted June 28, 2007 hi I am having problem in compiling my JSP code with Jasper reports in eclipse , I get general exception . But as simple JSP the below code works fine in tomcat. I think i need some help in how to compile and also the path and where to put the JRXML file in eclipse Pls check the attached code. <%@ page language="java"%><%@ page import="java.io.*" %><%@ page import="java.sql.*" %><%@ page import="java.lang.*" %><%@ page import="java.util.*" %><%@ page import="java.lang.ClassLoader"%><%@ page import="javax.sql.DataSource" %><%@ page import="javax.naming.InitialContext" %><%@ page import="net.sf.jasperreports.engine.*" %><%@ page import="net.sf.jasperreports.engine.xml.JRXmlLoader" %><%@ page import="net.sf.jasperreports.engine.design.JasperDesign" %><%@page session="true" %> <% JasperReport jasperReport; JasperPrint jasperPrint; Map parameters = new HashMap(); Statement st; JRResultSetDataSource obj; ResultSet rs; try { String customername=session.getValue("cname").toString(); Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/pentagon","root",""); JasperDesign design = JRXmlLoader.load(application.getRealPath("/WEB-INF/reports/sample.jrxml")); jasperReport = JasperCompileManager.compileReport(design); byte[] bytes = JasperRunManager.runReportToPdf(jasperReport,parameters,conn); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); ouputStream.close(); } catch(JRException e) { }%> 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