Friday Project Test completed no problem after the online, after the online found that some accounts do not log on
As a result, cookies are included in the cookie used to record the tracking user. Read, an exception occurred while writing.
The exception is probably like this:
Java.lang.IllegalArgumentException:Control character in cookie value or attribute.
At Org.apache.tomcat.util.http.CookieSupport.isHttpSeparator (cookiesupport.java:193)
At Org.apache.tomcat.util.http.CookieSupport.isHttpToken (cookiesupport.java:217)
At Org.apache.tomcat.util.http.ServerCookie.appendCookieValue (servercookie.java:186)
At Org.apache.catalina.connector. Response.generatecookiestring (response.java:1032)
At Org.apache.catalina.connector. Response.addcookie (response.java:974)
At Org.apache.catalina.connector. Responsefacade.addcookie (responsefacade.java:381)
At Com.vcfilm.interceptor.service.AutologonService.setCookie (autologonservice.java:168)
At Com.vcfilm.interceptor.service.AutologonService.saveLogonInfo (autologonservice.java:129)
At Com.vcfilm.interceptor.service.AutologonService.saveLogonInfo (autologonservice.java:139)
At Com.vcfilm.wechat.actioncommon.BaseAction.SaveSession (baseaction.java:45)
At Com.vcfilm.wechat.actioncommon.BaseAction.SetMember (baseaction.java:191)
At Com.vcfilm.wechat.member.MemberAction.logincheck (memberaction.java:364)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:601)
Chinese need Urlencoder.encode. Utf-8
Can participate in this article http://blog.csdn.net/newyear1988/article/details/7817066
Added after the discovery still has a problem, write a cookie with DES encryption, found to take Cookie,getval () after the decryption of the time of the exception, so in the catch exception code block directly returned Getval () to get the value.
/*** Take a value from the cookie **/ Publicstring Getcookieval (HttpServletRequest request, string key) {cookie[] cookies=request.getcookies (); if(NULL! = Cookies && cookies.length > 0){ for(Cookie c:cookies) {if(C.getname (). Equalsignorecase (Key)) {if(NULL!=c) { Try{ returnUrldecoder.decode (C.getvalue (), "Utf-8"); }Catch(Exception e) {e.printstacktrace (); returnC.getvalue (); } } } } } return""; } /*** Save value to Cookie **/ Public voidSetcookie (String key, String Val,intMaxAge) { Try{val= Urlencoder.encode (val, "Utf-8")); }Catch(Exception e) {e.printstacktrace (); } Cookie Cookie=NewCookie (Key, Val); if(MaxAge > 0) {cookie.setmaxage (maxAge); } Cookie.setpath ("/"); Servletactioncontext.getresponse (). Addcookie (cookie); }
The cookie contains problems caused by Chinese