2005 IR Help Posted August 27, 2006 Share Posted August 27, 2006 By: Christianto Sahat - csahat My report doesn't show up from servlet 2004-12-21 18:50 Hi all, I have a problem with Jasper report. I've already design the report using iReport. The report is just a simple static text. It was already compile successfully, and I could view using iReport viewer. But when I tried to run it from servlet, there's only blank pdf page, and there's no static text I've written. There was no error when I tried to debug the code. What's wrong ? This is snippet of my source code : try { ServletContext context = this.getServletConfig().getServletContext(); System.setProperty( "jasper.reports.compile.class.path", context.getRealPath("/WEB-INF/lib/jasperreports-0.5.3.jar") + System.getProperty("path.separator") + context.getRealPath("/WEB-INF/classes/") ); System.setProperty( "jasper.reports.compile.temp", context.getRealPath("/WEB-INF/reports/") ); byte[] bytes = null; try { File reportFile = new File(context.getRealPath( "/WEB-INF/reports/exports/workorder/WorkOrderRpt.jasper")); Map parameters = new HashMap(); parameters.put("TWORKORDER_PK", "1"); parameters.put("PATH_IMAGE","1"); bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, new ConnectionFactory().getConnection()); if (bytes != null && bytes.length > 0) { httpServletResponse.setContentType("application/pdf"); httpServletResponse.setContentLength(bytes.length); ServletOutputStream ouputStream = httpServletResponse.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); ouputStream.flush(); ouputStream.close(); } bytes=null; } catch (JRException e) { e.printStackTrace(); return; } } catch (IOException ie) { ie.printStackTrace(); } } By: Alexander Wallace - aows RE: My report doesn't show up from servlet 2004-12-22 20:01 are you using IE and pdf viewer embedded in broser? Try saving the link instead and see if the report works, there is a bug in IE/pdf in certanin situations 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