Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying Empty jasper report with parameters java.sql.Timestamp using Servlet
    text
    copied!<p>I am new to jasper report. I had successfully created the report using iReport 3.5.2, in iReport date type is java.sql.Timestamp and taking date input as (Wed 12/06/2013) i am using Eclipse IDE and formatting the date in servlet code, but Timestamp value is coming(2013-06-12 00:00:00.000), and it is displaying empty jasper report. I am using following jars :-</p> <p>commons-beanutils-1.5.jar<br> commons-collections-2.1.jar<br> commons-digester-1.7.jar<br> commons-logging-1.0.2.jar<br> commons-logging-api-1.0.2.jar<br> groovy-all-1.5.5.jar<br> itext-2.1.5.jar<br> jasperreports-3.5.2.jar<br> jdt-compiler.jar<br> jfreechart-1.0.0-rc1.jar<br> jtds-1.2.jar</p> <p>Please find the below servlet code and please help me to display report with data.</p> <p>public String generateReport(HttpServletRequest request, HttpServletResponse response)</p> <pre><code>{ try { Connection connection = null; JasperReport jasperReport = null; JasperPrint jasperPrint=null; Date today = null; Timestamp date = null; String dateString = ""; connection = EmployeeJDBCUtil.getConnection(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd/MM/yyyy); try { dateString = dateFormat.format(new Date()); today = dateFormat.parse(dateString); Timestamp ts = new Timestamp(today.getTime()); } catch (ParseException e1) { e1.printStackTrace(); } Map parameters = new HashMap(); parameters.put("Date", ts ); String report_File = "D:/timesheet/EmployeeTimeSheet/WebContent/TimeSheet2.jrxml"; File report_FileName = new File(report_File); if(report_FileName.exists()) { try { JasperDesign jasperDesign = JRXmlLoader.load(report_File); jasperReport = JasperCompileManager.compileReport(jasperDesign); jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,connection); JasperExportManager.exportReportToPdfFile(jasperPrint, "D:/sample.pdf"); JasperViewer.viewReport(jasperPrint); } catch (Exception e) { e.printStackTrace(); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if(connection != null) try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } return "index.jsp"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload