Displaying JFreeChart in a web page using Struts2
- by Kingshuk
I am using Struts2. I need to display JFreeChart in a web page. Can any body help me on that?
Edit: it is getting displayed in binary format.
public String execute() throws Exception {
System.out.println("Refresh bar Chart");
response.setContentType("image/png");
OutputStream outstream = response.getOutputStream();
try {
JFreeChart chart = getChartViewer();
ChartUtilities.writeChartAsPNG(outstream, chart, 500, 300);
System.out.println("Created bar Chart");
return SUCCESS;
} finally {
outstream.close();
response.flushBuffer();
}
}