delete cookie from HttpServletResponse - Java Servlet JSP

Java examples for Servlet JSP:Cookie

Description

delete 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 delete(HttpServletResponse response,
            String cookieName) {/*  ww w .  j a  v a  2 s . c  o m*/
        Cookie eraser = new Cookie(cookieName, null);
        eraser.setMaxAge(0);
        response.addCookie(eraser);
    }
}

Related Tutorials