Java examples for Servlet JSP:Cookie
has Cookie in HttpServletRequest
import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Main{ public static boolean hasCookie(HttpServletRequest request, String name) { Cookie[] cookies = request.getCookies(); boolean foundCookie = false; for (int i = 0; i < cookies.length; i++) { Cookie cookie1 = cookies[i]; if (cookie1.getName().equals(name)) { foundCookie = true;/* w w w . j av a 2 s.com*/ } } return foundCookie; } }