Java examples for Servlet JSP:Cookie
clean servlet Cookie
import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; public class Main{ public static boolean cleanCookie(HttpServletResponse response, String[] keys) {// www . ja v a2s . co m return UtilCookie.setCookie(response, 0, keys, new String[keys.length]); } public static boolean setCookie(HttpServletResponse response, int maxAge, String[] keys, String[] values) { if (keys != null && values != null && keys.length == values.length) { maxAge = maxAge < -1 ? -1 : maxAge; for (int i = 0; i < keys.length; i++) { Cookie myCookie = new Cookie(keys[i], values[i]); myCookie.setPath("/"); myCookie.setMaxAge(maxAge); response.addCookie(myCookie); } return true; } return false; } }