Display chart+map with struts1

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Wo_OT
Posts: 1
Joined: Thu Feb 16, 2012 2:35 pm
antibot: No, of course not.

Display chart+map with struts1

Post by Wo_OT » Thu Feb 16, 2012 2:47 pm

Hi everyone,

I am trying to display a chart with its map on a jsp page and using struts framework.
Here is the code I am using right now :

Action code

Code: Select all

JFreeChart chart;
String mapName;
response.setContentType("image/png");
HttpSession session = request.getSession();
OutputStream out = response.getOutputStream();

[...]

ChartRenderingInfo info = new ChartRenderingInfo(
				new StandardEntityCollection());
		
ChartUtilities.writeChartAsPNG(out, chart, 400, 300, info);

String map = ImageMapUtilities.getImageMap(mapName, info);
session.setAttribute("chartMap", map);
JSP Page

Code: Select all

<img src='Chart.do?action=getChart' usemap="#chartMap<%=i%>"/>                
<%=session.getAttribute("chartMap") %>   
My problem is that when the page is first loaded the "chartMap" attribute does not exist in the session, I have to reload the page to get the attribute and then everything is displayed fine.

Is there another solution to send the map so that it apperas on the first loading of the page ?

Thank you

Locked