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") %>">

posted @ 2012-10-12 13:00  人生如若初见  阅读(506)  评论(0编辑  收藏  举报