my problem: i have a jsp where a button press will send a ID to the servlet. with the iD, my Servlet will send it further to a method, to use a sql statement to fetch data from the database base on the id. it all works fine, even the chart.
but now i want to include the chart back to my jsp and let the user see it without changing sites. with the outputstream it will stay on the servlet, and if i want to change my data, i need to go back. i tried going for the saveasPng route, but java always say that path was not found.
any help is appreciated.
OutputStream outputStream = response.getOutputStream();
response.setContentType("image/png");
int width = 500;
int height = 350;
ChartUtilities.writeChartAsPNG(outputStream, chart, width, height);
// try {
// final ChartRenderingInfo info = new
// ChartRenderingInfo(new StandardEntityCollection());
//
// final File file1 = new File(request.getContextPath() + "WebContent/images/piechart.png");
// ChartUtilities.saveChartAsPNG(
// file1, chart, 600, 400, info);
// System.out.println("hallo TRue");
// } catch (Exception e) {
// e.printStackTrace();
// }
request.setAttribute("imagePath", request.getContextPath() + "/WebContent/images/piechart.png");
request.setAttribute("chart", chart);
//request.getRequestDispatcher("Diagramm.jsp").forward(request, response);