I have designed a report in ireport of jasper report .To compile and execute that report we have to place the following jar files into lib folder of our WEB-INF folder
Jar file Names:
1. commons-collections-3.2.1.jar
2. commons-beanutils-1.8.2.jar
3. commons-digester.1.7.jar
4. jasperreports-4.5.0.jar
5. commons-logging-1.1.1.jar
6. itext2.1.7.jar
7. asm-3.3.jar
8. antlworks-1.4.3.jar
9. servlet-api.jar
10. groovy-all-1.7.jar
These are the common jar files required.
Write a Servlet that generates PDF report from out compiled jasper report. The servlet code of a demo servlet is shown below . Please ffollow the code....
code:
HashMap hm = null;
String jrxmlFileName = getServletContext().getRealPath("\\jrxml")+"\\demoreport.jrxml";
String jasperFileName =getServletContext().getRealPath("\\jrxml")+"\\demoreport.jasper";
String pdfFileName = getServletContext().getRealPath("\\jrxml")+"\\demoreport.pdf";
JasperCompileManager.compileReportToFile(jrxmlFileName,jasperFileName);
hm = new HashMap();
hm.put("ID", "123");
hm.put("DATENAME", "April 2006");
JasperPrint jasperPrint = (JasperPrint) JasperFillManager.fillReport(jasperFileName,hm, new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(jasperPrint, pdfFileName);
System.out.println("report generated...");
------------------------------------------------------------------------------------------------------------
The Above code generates required PDF report from jasper report into a folder where jasper report files are kept...