It is disgusting to encounter this exception. In Tomcat7 environment, this exception will be raised if the user’s name appears in Chinese when logging in. After the exception is caused, the user who cannot log in normally needs to delete the browser’s cookie information. Later, I checked the Internet and found out that the problem was Chinese transcoding. The abnormal information is as follows:
java.lang.IllegalArgumentException: Control character in cookie value or attribute.
at org.apache.tomcat.util.http.CookieSupport.isV0Separator(CookieSupport.java:155)
at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:323)
at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:157)
at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:98)
at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:913)
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:683)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:400)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Cookie is encoded by Unicode in Chinese and ASCII in English when storing the value, so the data needs to be transcoded when storing the Chinese value, and the data also needs to be transcoded when storing the value.
There are two solutions, one is a Cookie written in Java, and the other is a Cookie written in JavaScript.
The solution is as follows:
Java:
Encode: URLEncoder. Encode (name, “UTF-8”);
Decode.decode (name, “UTF-8”);
Decode.decode (name, “UTF-8”);
JavaScript:
Code: the escape (name);/encodeURI(name);
decode: unescape(name);/decodeURI(name);
The Servlet setting cookies to view the article: http://blog.csdn.net/twilight041132/article/details/46482983
Read More:
- Error: (serious: a child container failed during start) (server component failed to start so Tomcat is unable)
- A child container failed during start
- tomcat Issues org.apache.catalina.LifecycleException: Failed to start component
- Spring jacjson version conflict “nosuchme” thodError:com.fasterxml.jackson.databind.ObjectMapper.canSerialize “
- MongoDB Error: Query failed with error code 2 and error message ‘Field ‘locale’ is invalid
- A child container failed during start Tomcat error prompt
- Freemarker Failed at: ${ findObj.applyDateStart? string(“yyyy-MM… Template
- SQL state [null]; error code [0]; Error; nested exception is java.sql.SQLException: Error] with root
- Caused by: org.apache.catalina.LifecycleException: A child container failed during start
- failed to lazily initialize a collection of role: ……, no session or session was closed
- Maven failed to start component [standard engine [Tomcat] when using tomcat7 Maven plugin plug-in run
- Failed to start component [standardengine [Catalina]. Standardhost [localhost]. Standardcontext
- com.netflix.zuul.exception.ZuulException: Forwarding error
- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure (How to Fix)
- Tomcat9 Error: Could not find or load main class org.apache.catalina.startup.Bootstrap
- Failed to obtain JDBC Connection
- ajp_read_header: ajp_ilink_receive failed
- java.sql.SQLException: The Network Adapter could not establish the connection
- org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standar
- Solution to Tomcat starting error listener start