if (chart != null) {
OutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType("image/png");
chart.exportChartAsPNG(out);
} catch (Exception e) {
LOG.error("Generating chart " + chart.getClass().getName(), e);
} finally {
Closeables.closeQuietly(out);
}