Home > DeveloperSection > Interviews > How do you delete a Cookie within a JSP?

Posted on    May-21-2011 9:03 AM

 Java Java 
Ratings:
 1 Answer(s)
  1099  View(s)
Rate this:

Awadhendra Tiwari

Total Post:510

Points:2550
Posted on    May-21-2011 12:00 AM

We can create a cookie in jsp by using following code snippet
Cookie cook1= new Cookie("name","value");
response.addCookie(cook1);
We can delete cookie using following code snippet
Cookie killmycook = new Cookie("cook1","value");
killmycook.setMaxAge(0);
killmycook.setPath("/");
killmycook.addCookie(killmycook);

Don't want to miss updates? Please click the below button!

Follow MindStick