[abportal] Annotation of /src/main/java/eu/smartlm/abs/portal/graph/servlet/DrawPieChartServlet.java
Annotation of /src/main/java/eu/smartlm/abs/portal/graph/servlet/DrawPieChartServlet.java
Parent Directory
| Revision Log
Revision 1 -
(view)
(download)
1 : |
dgarcia |
1 |
package eu.smartlm.abs.portal.graph.servlet;
|
2 : |
|
|
|
3 : |
|
|
import java.io.IOException;
|
4 : |
|
|
import java.io.OutputStream;
|
5 : |
|
|
|
6 : |
|
|
import javax.servlet.ServletException;
|
7 : |
|
|
import javax.servlet.http.HttpServlet;
|
8 : |
|
|
import javax.servlet.http.HttpServletRequest;
|
9 : |
|
|
import javax.servlet.http.HttpServletResponse;
|
10 : |
|
|
import javax.servlet.http.HttpSession;
|
11 : |
|
|
|
12 : |
|
|
import org.jfree.chart.ChartUtilities;
|
13 : |
|
|
import org.jfree.chart.JFreeChart;
|
14 : |
|
|
|
15 : |
|
|
public class DrawPieChartServlet extends HttpServlet {
|
16 : |
|
|
private static final long serialVersionUID = 8800080257427786322L;
|
17 : |
|
|
private int width = 400;
|
18 : |
|
|
private int height = 400;
|
19 : |
|
|
|
20 : |
|
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
21 : |
|
|
|
22 : |
|
|
HttpSession session = request.getSession();
|
23 : |
|
|
JFreeChart chart = (JFreeChart) session.getAttribute("graph");
|
24 : |
|
|
|
25 : |
|
|
OutputStream out = response.getOutputStream();
|
26 : |
|
|
response.setContentType("image/png");
|
27 : |
|
|
ChartUtilities.writeChartAsPNG(out, chart, width, height);
|
28 : |
|
|
out.close();
|
29 : |
|
|
}
|
30 : |
|
|
}
|
|