Buela Posted January 11, 2018 Share Posted January 11, 2018 Hi I have integrated Jasper Reports with JSP.The below code in written my JSP Page.At runtime I am getting this error.Please help me out.I am pretty new to this.When am executing its givingException: java.lang.IllegalStateException: getOutputStream() has already been called for this response Connection conn; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/studentinfo", "root", "adminuser"); File reportFile = new File(application.getRealPath("//report//apsreport.jasper"));//your report_name.jasper file //Map parameters = new HashMap(); //parameters.put("test_subjects","test_TermI"); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),null, conn); response.setContentType("application/pdf"); response.setContentLength(bytes.length); // ServletOutputStream outStream = response.getOutputStream(); //outStream.write(bytes, 0, bytes.length); // outStream.flush(); // outStream.close(); return; } catch (Exception ex) { ex.printStackTrace(); } 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