You need to set the same cookie with the value nulland the maximum age 0(and in the same way if you set a custom one) back to the answer HttpServletResponse#addCookie().
cookie.setValue(null);
cookie.setMaxAge(0);
cookie.setPath(theSamePathAsYouUsedBeforeIfAny);
response.addCookie(cookie);
, . . , == Long -128 127. equals(). , :
public void delete(MyType instance) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (Long.valueOf(cookie.getValue()).equals(instance.getId())) {
cookie.setValue(null);
cookie.setMaxAge(0);
cookie.setPath(theSamePathAsYouUsedBeforeIfAny);
response.addCookie(cookie);
}
}
}
}
, , request response . , ? , : ? , , .