Jump to content

Exception: java.lang.IllegalStateException: getOutputStream() has already been called for this response


Buela

Recommended Posts

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 giving

Exception:  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

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...