gmadhavi Posted March 18, 2009 Share Posted March 18, 2009 Hi friends,Here is my situation.I am creating jasper report of various outputs from java.I am getting it successful but i am getting blank pages when no data is retrived from backend query.I need to display some user friendly message from java on to webpage.1) Is there any way to do that? Can we catch any exception from Jasper--reportexporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); 2) I am unable to get images in html format.What do I need to change? Thanks... Code: HashMap parameters = new HashMap(); parameters.put("IP_ORG_ID",orgId); parameters.put("IP_INV_ORGANIZATION_ID",inv_organization_id); parameters.put("IP_CARRIER_CODE",carrierId); parameters.put("IP_USER_METHOD_MEANING",shipMethodStr); jasperReport = JasperCompileManager.compileReport(jasperDesign); Connection jdbcConnection = connectDB(databaseName, userName, password);jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jdbcConnection); OutputStream ouputStream = response.getOutputStream(); JRExporter exporter = null; if( "PDF".equalsIgnoreCase(reportType) ) { response.setContentType("application/pdf"); exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); } else if( "HTML".equalsIgnoreCase(reportType) ) { exporter = new JRHtmlExporter(); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); parameter <url-pattern>/image</url-pattern> exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"images/aasc_logo.gif"); }exporter.exportReport(); Link to comment Share on other sites More sharing options...
C-Box Posted March 18, 2009 Share Posted March 18, 2009 to first question: Set the attribute "WhenNoData" to "NO PAGES" and check the pages >0 of the returned JasperPrint after fill. to secondno glue (as not working with html-exporter) :-( hthC-Box 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