parameters = new HashMap();
if (exporterParams == null)
exporterParams = new HashMap();
JasperPrint _jasperPrint = DynamicJasperHelper.generateJasperPrint(dynamicReport, layoutManager, ds,parameters);
final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, DJConstants.FORMAT_HTML, parameters);
parameters.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);
Map imagesMap = new HashMap();
JRExporter exporter = reportWriter.getExporter();
exporter.setParameters(exporterParams);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + "/" + imageServletUrl + "?image=");
// Needed to support chart images:
exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
HttpSession session = request.getSession();
session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, _jasperPrint);
session.setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);
//write generated HTML to the http-response (the one you got from the helper)
reportWriter.writeTo(response);
}