title: An issue with Jasper Report
body: <p>I am stuck with JasperReports. I have developed the report using iReport. When I run the report in iReport, it works perfectly. But when I call the report through servlet in my application, for the first call, it works fine. If I call the report second time, it shows as "The Document has No pages" even though my database is having required data. And again if I restart my tomcat server and call the same report, It again works fine. Report giving the problem when I make a second call. Can anyone helps me here?</p>
  
  <pre><code>public class Repor extends JFrame {
  
      HashMap hm = null;
      Connection con = null;
      String reportName;
  
      public Repor() {
          setExtendedState(MAXIMIZED_BOTH);
          setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      }
  
      public Repor(HashMap map) {
          this.hm = map;
          setExtendedState(MAXIMIZED_BOTH);
          setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      }
  
      public Repor(HashMap map, Connection con) {
          this.hm = map;
          this.con = con;
          setExtendedState(MAXIMIZED_BOTH);
          setDefaultCloseOperation(DISPOSE_ON_CLOSE);
          setTitle("Report Viewer");
      }
  
      public void setReportName(String rptName) {
          this.reportName = rptName;
      }
  
      public void callReport() {
          JasperPrint jasperPrint = generateReport();
          JRViewer viewer = new JRViewer(jasperPrint);
          Container c = getContentPane();
          c.add(viewer);
          this.setVisible(true);
      }
  
      public void callConnectionLessReport() {
          JasperPrint jasperPrint = generateEmptyDataSourceReport();
          JRViewer viewer = new JRViewer(jasperPrint);
          Container c = getContentPane();
          c.add(viewer);
          this.setVisible(true);
      }
  
      public void closeReport() {
      }
  
      /** this method will call the report from data source*/
      public JasperPrint generateReport() {
          try {
              if (con == null) {
                  try {
                      con = Database.getConnection();
                  } catch (Exception ex) {
                      ex.printStackTrace();
                  }
              }
              JasperPrint jasperPrint = null;
              if (hm == null) {
                  hm = new HashMap();
              }
              try {
                  /**You can also test this line if you want to display 
                   * report from any absolute path other than the project root path*/
                  jasperPrint = JasperFillManager.fillReport(reportName , hm, con);
              } catch (JRException e) {
                  e.printStackTrace();
              }
              return jasperPrint;
          } catch (Exception ex) {
              ex.printStackTrace();
              return null;
          }
      }
  
      /** call this method when your report has an empty data source*/
      public JasperPrint generateEmptyDataSourceReport() {
          try {
              JasperPrint jasperPrint = null;
              if (hm == null) {
                  hm = new HashMap();
              }
              try {
                  jasperPrint = JasperFillManager.fillReport(reportName + ".jasper", hm, new JREmptyDataSource());
              } catch (JRException e) {
                  e.printStackTrace();
              }
              return jasperPrint;
          } catch (Exception ex) {
              ex.printStackTrace();
              return null;
          }
      }
  }
  </code></pre>