Jump to content
JasperReports Library 7.0 is now available ×

[newbie] - Blank Report generated in struts


woeijing

Recommended Posts

Good day to all,

 

i try figure out how the struts action to call jasper report.

 

below is the details :

 

report name : rpt_creditnote.jasper

location : C:jakarta-tomcat-5.5.9webappsusahawanWEB-INFreport

 

intention : to make sure the report is call successfully, this report

have some static string inside but no parameters yet.

 

i use the below code to call report, it show only blank report with no static text where i have put in for testing, i put under page header part of report

 

 

Code:

Map parameters = new HashMap();
JasperReport jasperReport = (JasperReport) JRLoader.loadObject("C:\jakarta-tomcat-5.5.9\webapps\usahawan\WEB-INF\report\rpt_creditnote.jasper"«»);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(new ArrayList());
JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, parameters, ds);
jasperPrint.setName("SA9"«»);
response.setContentType("application/pdf"«»);
ServletOutputStream outStream = response.getOutputStream();
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, outStream);
exporter.exportReport();
outStream.flush();
outStream.close();
forward = mapping.findForward("success"«»);
return forward;

 

my questions :

 

1. why it called successfully but no static text inside the report

2. i have forward it to "success", which is using tiles and it suppose have one menu page on top and result page at bottom(report should put in result page). in my trial code above, it just give me a new blank report but not in specific layout that i have mentioned.am i in right approach ?

 

3. can someone provide me better example to display report in struts framework ?

 

thank you very much for reading and guiding me, your help is highly appreciated , have a nice day :)

Post edited by: woeijing, at: 2007/04/24 15:37

Link to comment
Share on other sites

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