jsp에서 쿠키 값을 가져오는 방법

833 단어 cookie
Cookie cookies[]=request.getCookies(); //        Cookie,     Cookie    cookie      
Cookie sCookie=null; 
for(int i=0;i<cookies.length-1;i++){    //              Cookie    
sCookie=cookies[i];   //        Cookie  
if(sCookie!=null){
      if(("cookieName").equals(sCookie.getName())){      
        pageContext.setAttribute("SavedUserName",sCookie.getValue());
      }
   }

//      cookies

String user_name=request.getParameter("user_name");
if(!"".equals(user_name) && request.getParameter("RmbUser")!=null){
Cookie cookie=new Cookie("usernamecookie",user_name);
cookie.setMaxAge(365*24*60*60); //  365 
response.addCookie(cookie); // COOKIE
}


좋은 웹페이지 즐겨찾기