Jump to content
We've recently updated our Privacy Statement, available here ×

How to handle when no data returned from jasper


gmadhavi

Recommended Posts

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

  • Replies 1
  • 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...