Java examples for Servlet JSP:Cookie
get Cookie value from HttpServletRequest
import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Main{ public static String getCookie(HttpServletRequest request, String name) { Cookie[] cookies = request.getCookies(); for (int i = 0; i < cookies.length; i++) { Cookie cookie1 = cookies[i]; if (cookie1.getName().equals(name)) { return cookie1.getValue(); }/*from w w w .j a v a2 s .co m*/ } return null; } }