thgr86 Posted September 23, 2014 Posted September 23, 2014 hello, PDF report with JasperReport getting the following error when I try to getthanks<Sep 24, 2014 12:16:05 AM EEST> <Error> <HTTP> <BEA-101104> <Servlet execution in servlet context "ServletContext@1412605140[app:IReports module:IReports-ViewController-context-root path:null spec-version:3.0]" failed, java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '806' bytes instead of stated: '-1' bytes..java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '806' bytes instead of stated: '-1' bytes. at weblogic.servlet.internal.ServletOutputStreamImpl.ensureContentLength(ServletOutputStreamImpl.java:481) at weblogic.servlet.internal.ServletResponseImpl.ensureContentLength(ServletResponseImpl.java:1549) at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1623) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1582) at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255) Truncated. see log file for complete stacktrace> [/code] FileBufferedOutputStream fbos = new FileBufferedOutputStream(); try { HttpServletResponse response = ru.getResponse(); ServletOutputStream outputStream = response.getOutputStream(); JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(list); BufferedInputStream fs = new BufferedInputStream(new FileInputStream(jasperDir + reportName + ".jasper")); JasperReport template = (JasperReport) JRLoader.loadObject(fs); template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL); JasperPrint jasperPrint = JasperFillManager.fillReport(template, jasperParameter); JRPdfExporter jrpdfExporter = new JRPdfExporter(); jrpdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); jrpdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fbos); jrpdfExporter.exportReport(); fbos.close(); if (fbos.size() > 0) { response.setHeader("Content-Disposition", "attachment; filename="" + reportName + ".pdf""); response.setContentLength(fbos.size()); response.setContentType("application/pdf"); System.out.println(fbos.size()); try { fbos.writeData(outputStream); fbos.dispose(); outputStream.flush(); } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } outputStream.close(); } catch (Exception e) { e.printStackTrace(); } finally { fbos.dispose(); }[/code][/code]
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