<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@page import="org.jfree.chart.JFreeChart,org.jfree.data.general.DefaultPieDataset,org.jfree.chart.ChartFactory,
,org.jfree.chart.servlet.ServletUtilities;"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'jfreeChart.jsp' starting page</title>
</head>
<body>
<%
//jfreeChart.jsp为显示投票结果页面,具体项目中
//有一张vote表,其中有 votename,votecount,可以在用户按下投票按钮后,或查看结果时
//将请求发送到struts2等servlet中,这样在servlet中可以写 select votecount from vote
//将返回一个得票的数组,用一个int []votecount 来保存,并request.setAttribute("votecountarray",votecount)
//并配置跳转到jfreeChart.jsp页面中,这样在jfreeChart.jsp中可以通过迭代标签或request.getAttribute("votecountarray")
//来得到整形数组,这样可将“dpd.setValue”里的第二个参数动态的设置为每个投票项的投票数目,这样就可以动态创建投票的
//结果了.
DefaultPieDataset dpd=new DefaultPieDataset();
dpd.setValue("seller", 25);
dpd.setValue("pineer", 40);
dpd.setValue("backer", 10);
dpd.setValue("orgnizeer", 25);
JFreeChart chart=ChartFactory.createPieChart3D("the employee of a company", dpd, true, true, true);
String fileName=ServletUtilities.saveChartAsJPEG(chart,800,600,session);
String url=request.getContextPath()+"/DisplayChart?filename="+fileName;
%>
<img src="<%=url%>" width="500" height="300">
</body>
</html>