title: generate pdf file from jasper report with servlet java code
body: <p>I have a jasper report, I put it in the same package as servlets, I need to generate pdf file from it, but the code doesn't work and doesn't gives any error</p>
  
  <pre><code>public void print(String numBac , HttpServletRequest request,
    HttpServletResponse response) {
      try {          
          JasperDesign jasperDesign = JRXmlLoader
                  .load("fiche.jrxml");
          String sql = "SELECT * FROM etudiant "
                  + "INNER JOIN filiere ON etudiant.code_f=filiere.code_f "
                  + "INNER JOIN lieu_nais ON etudiant.code_lieu=lieu_nais.code_lieu "
                  + "INNER JOIN montant ON etudiant.code_m=montant.code_m WHERE bac='"
                  + numBac + "'";
          JRDesignQuery newQuery = new JRDesignQuery();
          newQuery.setText(sql);
          jasperDesign.setQuery(newQuery);
          JasperReport report = JasperCompileManager
                  .compileReport(jasperDesign);
          //JasperPrint print = JasperFillManager.fillReport(report, null, cnx);
          //JasperViewer.viewReport(print);
  
          byte[] byteStream;
          byteStream = JasperRunManager.runReportToPdf(report, null, cnx);
          OutputStream outStream = response.getOutputStream();
          response.setHeader("Content-Sisposition", "inline,filename="+DOWNLOAD_FILE_NAME);
          response.setContentType(FILE_TYPE);
          response.setContentLength(byteStream.length);
          outStream.write(byteStream, 0, byteStream.length);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>even if I want to generate jasper preview it doesn't shown up (code in comment)</p>