生成图片的方法:
 public String generatePieChart(String title,HttpSession session,PrintWriter pw){
 
   String fileName=null;
   PiePlot plot=new PiePlot(dedefaltPic());
   plot.setInsets(new RectangleInsets(0, 5, 5, 5));
   //在统计图片上建立连接。
   plot.setURLGenerator(new StandardPieURLGenerator("http://localhost", "section"));
   plot.setToolTipGenerator(new StandardPieToolTipGenerator());
   JFreeChart chart=new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
   
    TextTitle titles= chart.getTitle();
titles.setFont(new Font("黑体",Font.BOLD,14));//设置标题文字
PiePlot piePlot=(PiePlot)chart.getPlot();//获取图表区域对象
piePlot.setLabelFont(new Font("黑体", Font.BOLD, 12)); //饼图旁边的中文
chart.getLegend().setItemFont(new Font("黑体",Font.BOLD, 12));//设置底部中文
ChartRenderingInfo info=new ChartRenderingInfo(new StandardEntityCollection());
try {

        fileName=ServletUtilities.saveChartAsPNG(chart, 500, 300,info, session);
       // PrintWriter pws =new PrintWriter(fileName);
//            ChartUtilities.writeImageMap(pw, fileName, info,false);
//            pw.flush();
}
        catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        }

   return fileName;
Action中方法:
public String webChart(){
WebChart  chart=new WebChart();
OutputStream out=null;
try {
// out=this.getResponse().getOutputStream();
//     PrintWriter pw=new PrintWriter(out);
        this.fileName=chart.generatePieChart("水果产量图",ServletActionContext.getRequest().getSession(), null);
        }
        catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        }

fileName=  ServletActionContext.getRequest().getContextPath()+"servlet/DisplayChart?filename="+fileName;
out=null;
return "toWebChart";
}jsp中调用
 <img alt="aaa" src="${fileName}" width="400" height="300">生成的路径是src=" /snpecservlet/DisplayChart?filename=jfreechart-6151396563597141489.png"