I'm using the following function to create a cookie which is set in a Java Servlet. I am trying to delete it in a scriptlet in a .JSP file. However it is not deleting the cookie, any ideas as to why?
This is the function that I am using to create the cookie in the Servlet:
    for(String classId :request.getParameterValues("classId")){
        optionCookie = new Cookie("componentSearchOptionSelect",classId);
        response.addCookie(optionCookie);
    }
This is the code I am using to delete the cookie in the scriptlet:
Cookie[] cookies = null;
        cookies = request.getCookies();
        if(cookies != null){
            for(int i = 0; i < cookies.length; i++){
                 Cookie cookie = cookies[i];
                 if(cookie.getName().equals("componentSearchOptionSelect")){
                     selectedClass = cookie.getValue();
                     cookie.setMaxAge(0);
                     response.addCookie(cookie);
                 }
             }
        }
 
     
     
    