// If a persistence service is specified, find the provider
String serviceName = req.getParameter("service");
ChartProvider provider = getChartProviders().get(providerName);
if (provider == null)
throw new ServletException("Could not get chart provider.");
// Set the content type to that provided by the chart provider
res.setContentType("image/" + provider.getChartType());
try {
BufferedImage chart = provider.createChart(serviceName, null, timeBegin, timeEnd, height, width,
req.getParameter("items"), req.getParameter("groups"));
ImageIO.write(chart, provider.getChartType().toString(), res.getOutputStream());
} catch (ItemNotFoundException e) {
logger.debug("Item not found error while generating chart.");
} catch (IllegalArgumentException e) {
logger.debug("Illegal argument in chart: {}", e);
}