Created
July 7, 2013 22:45
-
-
Save scsibug/5945259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void service(ServletRequest req, ServletResponse res) | |
throws ServletException, IOException { | |
RrdGraphDef graphDef = new RrdGraphDef(); | |
configureImageParameters(graphDef, req); | |
configureContents(graphDef, req); | |
try { | |
RrdGraph graph = new RrdGraph(graphDef); | |
BufferedImage bi = new BufferedImage(graph.getRrdGraphInfo().getWidth(), graph.getRrdGraphInfo().getHeight(), BufferedImage.TYPE_INT_RGB); | |
graph.render(bi.getGraphics()); | |
res.setContentType("image/png"); | |
javax.imageio.ImageIO.write(bi, "png", res.getOutputStream()); | |
} catch(FileNotFoundException e) { | |
throw new ServletException("Could not read database files for all requested items.", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
servlet to write RRD4j graphs directly to a client.