europe72 Posted May 26, 2011 Share Posted May 26, 2011 Hello, I'm currently in the process of coding a Servlet, which creates a JasperPrint object, and subsequently exports it via JRExporter. Below is a snippet of code from that Servlet. I was attempting to create a File obj from the OUTPUT_FILE, however OUTPUT_FILE is null even after exportReport() is called. Should it be? Code:... ServletOutputStream os = response.getOutputStream(); exp.setParameter(JRExporterParameter.CHARACTER_ENCODING, p.get("encoding")); exp.setParameter(JRExporterParameter.JASPER_PRINT, jp); exp.setParameter(JRExporterParameter.OUTPUT_STREAM, os); try { exp.exportReport(); } catch (JRException e) { response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getLocalizedMessage()); e.printStackTrace(); } File f = (File) exp .getParameter(JRExporterParameter.OUTPUT_FILE); response.setContentLength((int) f.length()); os.flush(); os.close();... 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