if ("html".equals(condition)) {
PrintWriter pw = response.getWriter();
response.setContentType("text/html;charset=UTF-8");
response.setHeader("pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
JRHtmlExporter html = new JRHtmlExporter();
html.setParameter(JRExporterParameter.JASPER_PRINT, print);
html.setParameter(JRExporterParameter.OUTPUT_WRITER, pw);
html.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
html.setParameter(JRHtmlExporterParameter.IMAGES_URI, "./images/");
html.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,
this.getServletContext().getRealPath("/images") + "\\");
html.exportReport();
pw.flush();
pw.close();
} else if ("pdf".equals(condition)) {
response.setContentType("application/pdf;charset=utf-8");
response.setHeader("Content-Disposition", "inline;filename=\""// attachment,inline
+ type + ".pdf\"");
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE);
exporter.setParameter(JRPdfExporterParameter.IS_128_BIT_KEY, Boolean.TRUE);
exporter.setParameter(JRPdfExporterParameter.PERMISSIONS,
Integer.valueOf(String.valueOf(PdfWriter.AllowCopy | PdfWriter.AllowPrinting)));
exporter.exportReport();
}
PrintWriter pw = response.getWriter();
response.setContentType("text/html;charset=UTF-8");
response.setHeader("pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
JRHtmlExporter html = new JRHtmlExporter();
html.setParameter(JRExporterParameter.JASPER_PRINT, print);
html.setParameter(JRExporterParameter.OUTPUT_WRITER, pw);
html.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
html.setParameter(JRHtmlExporterParameter.IMAGES_URI, "./images/");
html.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,
this.getServletContext().getRealPath("/images") + "\\");
html.exportReport();
pw.flush();
pw.close();
} else if ("pdf".equals(condition)) {
response.setContentType("application/pdf;charset=utf-8");
response.setHeader("Content-Disposition", "inline;filename=\""// attachment,inline
+ type + ".pdf\"");
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE);
exporter.setParameter(JRPdfExporterParameter.IS_128_BIT_KEY, Boolean.TRUE);
exporter.setParameter(JRPdfExporterParameter.PERMISSIONS,
Integer.valueOf(String.valueOf(PdfWriter.AllowCopy | PdfWriter.AllowPrinting)));
exporter.exportReport();
}