title: Displaying JFreeChart in a web page using Struts2
body: <p>I am using Struts2. I need to display JFreeChart in a web page. Can any body help me on that?</p>
  
  <p>Edit: it is getting displayed in binary format.</p>
  
  <pre><code>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();
      }
  }
  </code></pre>