太长,没时间看.
给你个参考!
sendRedirect ()错误例子
Note:在servlet里面,如果已经有一个response返回给客户端,在这个response里就不能再跟sendRedirect(),不然会产生一个IllegalStateException错误,比如:
PrintWriter pw = res.getPrintWriter();
pw.println("<html><body>Hello World!</body></html>");
pw.flush();   //Sends the response
res.sendRedirect("http://www.cnn.com");  //Tries to redirect
这样就会引发错误。