Thanks.
I did this long back but it skipped my mind.

-Sameer

Yogesh Agarwal wrote:
>
> Hi Sameer,
> take a look at the code below .. the changes are between the
> asterisk lines. This will do the trick, I have actually tested
> the code.
> Basically, you need to create a new cookie with the same name and value and
> then set the age to zero. This will delete the cookie.
> Hope this helps.
>
> Yogesh
> #######################################################################
> >
> > public void service(HttpServletRequest request, HttpServletResponse
> > response) throws ServletException, IOException {
> >         Cookie[] cookies = request.getCookies();
> >
> >         PrintWriter out = response.getWriter();
> >
> >         response.setContentType("text/html");
> >
> >
> out.println("<html><head><title>ClearCookies</title></head><body>");
> >         out.println("<h2>ClearCookies</h2><hr>");
> >
> >         if (cookies != null) {
> >           for (int i = 0; i < cookies.length; i++) {
> >             out.println("Deleting: " + cookies[i].getName() + "<br>");
> //***********************************************************************
> // ADD THIS TO YOUR CODE
>
>         Cookie newCookie = new
> Cookie(cookies[i].getName(),cookies[i].getValue());
>                newCookie.setMaxAge(0);
>                response.addCookie(newCookie);
> //***********************************************************************
> >           }
> >
> >           out.println("<p>");
> >           out.println("<b>Your cookies have been deleted</b>");
> >         } else {
> >           out.println("<b>No cookies to delete</b>");
> >         }
> >
> >         out.println("<hr></body></html>");
> >
> >         out.close();
> >     }
> >
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to