JSP引入JFreeChart
JFreeChart chart = JFreeChartTool.ToLineChart(list);
try {
HttpSession session = ServletActionContext.getRequest()
.getSession();
String filename = ServletUtilities.saveChartAsPNG(chart, 500,
300, null, session);
System.out.println(filename);
String graphURL = request.getContextPath()
+ "/servlet/DisplayChart?filename=" + filename;
request.setAttribute("graphURL2", graphURL);
} catch (IOException e) {
e.printStackTrace();
}
页面中加入:
<img src="<%= request.getAttribute("graphURL2") %>">