具体问题如下:
HTTP Status 500 – Internal Server Error
Type 异常报告
消息 在 [37] 行处理 [/Example7-4-9/response.jsp] 时发生异常
描述 服务器遇到一个意外的情况,阻止它完成请求。
Exception
org.apache.jasper.JasperException: 在 [37] 行处理 [/Example7-4-9/response.jsp] 时发生异常
34: }else{
35: cookie_response=new Cookie(userName+"_access_time",new java.util.Date().toString());
36: }
37: response.addCookie(cookie_response);
38: response.setContentType(“text/html”);
39: response.flushBuffer();
40: %>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:626)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value
org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateCookieValue(Rfc6265CookieProcessor.java:189)
org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:115)
org.apache.catalina.connector.Response.generateCookieString(Response.java:973)
org.apache.catalina.connector.Response.addCookie(Response.java:925)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:385)
org.apache.jsp.Example7_002d4_002d9.response_jsp._jspService(response_jsp.java:153)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
):注意 主要问题的全部 stack 信息可以在 server logs 里查看
Apache Tomcat/9.0.33
解决办法,Tomcat版本过高,从9.0换成7.0之后就没有错误了。