Get cookie value in java

后端 未结 6 1866
悲&欢浪女
悲&欢浪女 2020-12-24 15:00

I\'ve initialized cooke like this in my JSP,

String timeStamp = new SimpleDateFormat(\"dd:MM:yyyy_HH:mm:ss:SSS\").format(Calendar.getInstance().getTime());
t         


        
6条回答
  •  余生分开走
    2020-12-24 15:25

    You are using the wrong method for reading the cookies..

    Cookie[] cookies = request.getCookies();
    
    if (cookies != null) {
     for (Cookie cookie : cookies) {
       if (cookie.getName().equals("cookieName")) {
         //do something
         //value can be retrieved using #cookie.getValue()
        }
      }
    }
    

    use this. No need to detect the cookie for particular user just deactivate it.

提交回复
热议问题