Displaying JFreeChart in a web page using Struts2

Posted by Kingshuk on Stack Overflow See other posts from Stack Overflow or by Kingshuk
Published on 2010-03-30T13:14:38Z Indexed on 2010/03/30 23:43 UTC
Read the original article Hit count: 643

Filed under:
|
|

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();
    }
}

© Stack Overflow or respective owner

Related posts about struts2

Related posts about jsp