Java examples for Servlet JSP:Cookie
get cookie from HttpServletRequest
import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Main{ public static Cookie get(HttpServletRequest request, String cookieName) { Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals(cookieName)) { return cookie; }/*from ww w. j a va 2 s . c o m*/ } } return null; } }