标签:
jsp代码提示String isUseCookie = request.getParameter("isUseCookie"); if(isUseCookie!=null) {//isUseCookie.equals("on") String username=loginUser.getName(); String password=loginUser.getPassword(); username = URLEncoder.encode(username,"utf-8"); password = URLEncoder.encode(password,"utf-8"); Cookie c = new Cookie("username",username); Cookie p = new Cookie("password",password); c.setMaxAge(604800);//单位秒,7天后失效 p.setMaxAge(604800);//单位秒,7天后失效 response.addCookie(c); response.addCookie(p); } else { Cookie[] cookies = request.getCookies(); boolean flag_name,flag_pwd; flag_name=flag_pwd=false; for (Cookie c:cookies) { if(flag_name==false && c.getName().equals("username")) { c.setMaxAge(0); response.addCookie(c); flag_name=true; } if(flag_pwd==false&&c.getName().equals("password")) { c.setMaxAge(0); response.addCookie(c); flag_pwd=true; } if(flag_pwd==flag_name&&flag_name==true) { break; } } } %>
flush表示被包含的页面是否从缓冲中读取
标签:
原文地址:http://blog.csdn.net/lxz26192/article/details/51347358