I haven't tried it, but how about adding this line of code:
response.addCookie(cookies[i]) ;
after the cookies[i].setMaxAge(0) statement ??
-Henning
Sameer Tyagi wrote:
> Hey Marc
> Did you find a solution to this ?
> I m facing the same problem
>
> Thanks
> -Sam
>
> Marc Tremblay wrote:
> >
> > Does anyone know how to actually delete a cookie as setMaxAge(0) doesn't
> > seem to do anything at all in the code below.
> >
> > 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>");
> > cookies[i].setMaxAge(0);
> > }
> >
> > 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();
> > }
> >
> > Marc Tremblay
> > Web Programmer
> > EyeWire Inc.
>
> ___________________________________________________________________________
> 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
begin:vcard
n:Brune;Henning
tel;fax:+49 (0)5 21/1 06-64 40
tel;work:+49 (0)5 21/1 06-29 48
x-mozilla-html:FALSE
org:Universitaet Bielefeld;Technische Fakultaet, AG TI
adr:;;Postfach 100131;Bielefeld;NRW;33501;Germany
version:2.1
email;internet:[EMAIL PROTECTED]
title:Dipl.-Inform.
fn:Henning Brune
end:vcard
S/MIME Cryptographic Signature