Michael McCormick wrote:

> I'm not particularly grounded in web development, so this may
> not be specific to Tomcat. I'm hoping someone can explain how
> this works.
>
> I can get cookies sent back to the browser when performing a
> redirect if I set them _after_ I issue the redirect. That is, if
> I write:
>
> <%
> response.sendRedirect("bar.jsp");
> response.addCookie(new Cookie("baz","quux"));
> %>
>

This should not work, because you're not allowed to modify the HTTP headers
after calling sendRedirect().

The fact that this works, and that the opposite order (which is the correct one)
fails are bugs in Tomcat 3.1.  You should really really really be using 3.2 or
later.

>
> Can someone please explain (or point to a resource) why a cookie
> doesn't "stick" unless I set it after I specify the redirect?
>
> Thanks in advance,
>
> Mike

Craig McClanahan


Reply via email to