title: display jfreecharts using servlets
body: <p>I have a scenario where I need to display charts(generated using jfreecharts) converted it into a png image and then display them using servlets.</p>
  
  <p>When the chart code extends either ApplicationFrame or Jframe I see the following exception when I display it using servlets :</p>
  
  <pre>
  java.awt.HeadlessException:
  No X11 DISPLAY variable was set, but this program performed an operation which requires it.
  at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
  at java.awt.Window.(Window.java:317)
  at java.awt.Frame.(Frame.java:419)
  at javax.swing.JFrame.(JFrame.java:194)
  </pre>
  
  <p>I read through a couple of places and this seems to be because of the ApplicationFrame and JFrame would cause this error.</p>
  
  <p>If i pass just the chart object this throws a </p>
  
  <pre>
  java.lang.IllegalArgumentException: Null 'chart' argument.
      org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:181)
      org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:136)
  </pre>
  
  <p>Is there any solution for this?</p>