Cannot create a session after the response has been committed:
之所以会出现此类问题是因为我们在Response输出响应后才创建Session的。
(因为那时候服务器已经将数据发送到客户端了,即:就无法发送Session ID 了)
解决办法:
你只需要在你的程序中将创建访问Session的语句【request.getSession()】提前至Response输出数据之前就好了。
HttpSession session = request.getSession(); //
OutputStream out2 = response.getOutputStream();
response.setContentType("image/png");
这样比较好
不要放在setContent之后
httpServletRequest request = ServletActionContext.getRquest();
HttpSession session = request.getSession();
String fileName = ServletUtilities.saveChartAsJPEG(chart,400,300,session);
graphURL = ServletActionContext.getServletcontext().getContextpath()+"/servlet/Display?filename"+filename