I've builded a servlet which make some Query to a database pick some information up and them forward it to the jsp page.
Apart of this information, now I wanted to include, as a request, a chart which has been created in the servlet.
Servlet code:
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
. More Servlet code..
.
.
.
case "Charts": {
String QueryStatus = "select distinct NodeStatus from nodes;";
Operations oper = new Operations();
ArrayList<?> ListStatus = oper.getList(QueryStatus);
request.setAttribute("ListStatus", ListStatus);
Till here everything works well, but once i add the following code:
JFreeChart Chart = null;
BACENGQueryDatabases DataChart = new BACENGQueryDatabases();
Chart = DataChart.GetChart("select Name, StNode from controls;");
if (Chart != null) {
int width = 500;
int height = 350;
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
response.setContentType("image/png");
OutputStream out = response.getOutputStream();
ChartUtilities.writeChartAsPNG(out, Chart, width, height, info);
}
The chart is printed but nothing else. The RequestDispatcher is truncate.
RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/Charts.jsp"); //Set page to redirect data
rd.forward(request, response);// Forward data to the next page
break;
}
Is there any way to forward the chart, like I'm doing with ( request.setAttribute("ListStatus", ListStatus);) to be used on the same jsp page.
I refuse to use print the chart to a file and then use it on jsp because the I/O performance, since many charts will be created.