remove Cookie from HttpServletResponse - Java Servlet JSP

Java examples for Servlet JSP:Cookie

Description

remove Cookie from HttpServletResponse

Demo Code


import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Main{
    public static void removeCookie(HttpServletResponse response,
            String name) {//ww  w. j  a va 2s  . c  o  m
        Cookie cookie = new Cookie(name, "");
        cookie.setMaxAge(0);
        response.addCookie(cookie);
    }
}

Related Tutorials