/** * We need to write text to the response Writer. * @param exporter the JasperReports exporter to use * @param populatedReport the populated <code>JasperPrint</code> to render * @param response the HTTP response the report should be rendered to * @throws Exception if rendering failed */ protected void renderReportUsingWriter( JRExporter exporter, JasperPrint populatedReport, HttpServletResponse response) throws Exception { // Copy the encoding configured for the report into the response. String contentType = getContentType(); String encoding = (String) exporter.getParameter(JRExporterParameter.CHARACTER_ENCODING); if (encoding != null) { // Only apply encoding if content type is specified but does not contain charset clause already. if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) { contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding; } } response.setContentType(contentType); // Render report into HttpServletResponse's Writer. JasperReportsUtils.render(exporter, populatedReport, response.getWriter()); }
/** * We need to write text to the response Writer. * @param exporter the JasperReports exporter to use * @param populatedReport the populated {@code JasperPrint} to render * @param response the HTTP response the report should be rendered to * @throws Exception if rendering failed */ protected void renderReportUsingWriter(net.sf.jasperreports.engine.JRExporter exporter, JasperPrint populatedReport, HttpServletResponse response) throws Exception { // Copy the encoding configured for the report into the response. String contentType = getContentType(); String encoding = (String) exporter.getParameter(net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING); if (encoding != null) { // Only apply encoding if content type is specified but does not contain charset clause already. if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) { contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding; } } response.setContentType(contentType); // Render report into HttpServletResponse's Writer. JasperReportsUtils.render(exporter, populatedReport, response.getWriter()); }
_imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.pdf", "pdf", "application/pdf", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.xml", "xml", "text/xml", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.html", "html", "text/html", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.rtf", "rtf", "application/rtf", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.xls", "xls", "application/vnd.ms-excel", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.xls", "xls", "application/vnd.ms-excel", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.csv", "csv", "text/csv", arrayOutputStream.toByteArray()); _imageMap = (Map)exporter.getParameter(JRHtmlExporterParameter.IMAGES_MAP); return _media = new AMedia("report.odt", "odt", "application/vnd.oasis.opendocument.text", arrayOutputStream.toByteArray());