This is the situation: My \'metrics.jsp\' page submits a couple variables that are needed to create the chart. The \'ProjectActionBean.java\' calls down to a few other java
You need to write a servlet which writes image (byte stream) into the output stream to the client. There are no need for creating files. Basically something like this should work:
public class ChartServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
JFreeChart chart = .. // create your chart
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(bos, chart, width, height);
response.setContentType("image/png");
OutputStream out = new BufferedOutputStream(response.getOutputStream());
out.write(bos.toByteArray());
out.flush();
out.close();
}
}
Then map it to some url in your web.xml and use from "img" tag in HTML/JSP. Obviously you can pass parameters to it etc.