Buela Posted January 10, 2018 Share Posted January 10, 2018 I have jrxml file which retrieves data from mysql database.I would like to run this file using jsp page.When am executing jsp page jrxml file should print data in pdf format .Here is my code File reportFile = new File(application.getRealPath("report/report1.jasper"));//report_name.jasper file Map parameters = new HashMap(); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),parameters, conn); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream outStream = response.getOutputStream(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); while executing its giving exception: org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 38 38:byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),parameters, conn); Can anybody please help me how to resolve this. Link to comment Share on other sites More sharing options...
hozawa Posted January 11, 2018 Share Posted January 11, 2018 You'll need to declare database connection ("conn" variable) to you mysql database.Connection conn;Class.forName("com.mysql.jdbc.Driver");conn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/<schema>?user=<username>&password=<password>"); Link to comment Share on other sites More sharing options...
Buela Posted January 11, 2018 Author Share Posted January 11, 2018 I have included that but still its giving blank response 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