toltsch Posted December 15, 2006 Share Posted December 15, 2006 Hello, This is more information on another post that I've made. I've found that when you use the net.sf.jasperreports.j2ee.servlets.ImageServlet to Dynamically display chart images it works the first time. I'm using Jasper Reports 1.2.8 (the latest) When you run the same report with different data you get the wrong image. It displays the image from the first run. It seems to never want to display the image from the current run, only the first. When I set the code to write to a directory it works perfectly, but this method is not desired since I have to store the image. Has anyone come across this and this? Code to use ImageServlet: JRHtmlExporter exporter = new JRHtmlExporter(); HashMap imagesMap = new HashMap(); request.getSession().setAttribute("IMAGES_MAP", imagesMap); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print); String serverName = request.getServerName();String serverPort = String.valueOf(request.getServerPort());if (serverPort != null && serverPort.trim().length() > 0) serverName = serverName + ":" + serverPort + "/";String servletPath = "jenasys/servlet/";exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getScheme()+"://"+serverName+servletPath+"net.sf.jasperreports.j2ee.servlets.ImageServlet?image="); exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,"<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body>"); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.exportReport(); Link to comment Share on other sites More sharing options...
toltsch Posted December 18, 2006 Author Share Posted December 18, 2006 It was the brower cache which caused this issue. I had to add a unique parameter to the ImageServlet. I added a parameter with the current date and time. Setting the response header of META data in the html output did not help expire the cache, this is why I added the parameter. Link to comment Share on other sites More sharing options...
xpdz Posted June 15, 2007 Share Posted June 15, 2007 Hi toltsch, could you please show me your code which you mensioned 'a unique parameter with the current date and time'?and what's the purpose of this line:request.getSession().setAttribute("IMAGES_MAP", imagesMap); thxI am using the 1.3.3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now