RE: headers, cookies, redirect
Title: RE: headers, cookies, redirect Flip it around, try % response.sendRedirect(bar.jsp); response.addCookie(new Cookie(baz,quux)); % it seems like sendRedirect resets the HTTP headers. -Original Message- From: Michael McCormick [mailto:[EMAIL PROTECTED]] Sent: Friday, November 17, 2000 12:08 PM To: [EMAIL PROTECTED] Subject: headers, cookies, redirect Summary: my headers and/or cookies aren't sent with the response when I send a redirect. Suppose I have a .jsp page foo.jsp: % response.addCookie(new Cookie(baz,quux)); response.sendRedirect(bar.jsp); % The response from foo.jsp (which is a 302) does _not_ contain a Set-Cookie header with the contents baz=quux. If I comment out the redirect line, the response (a 200) _does_ contain the appropriate header. Is there some special trick to adding headers to a redirect? Am I missing something obvious? Configuration: Apache 1.39 Tomcat 3.1 Blackdown Java 1.2.2 LinuxPPC 2.2.15 In a related question, how does one turn off the session id cookie that always gets sent. I notice Tomcat has no problems sending _that_ with a redirect. Thanks for any help, Mike
re: headers, cookies, redirect
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")); % 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
RE: headers, cookies, redirect
Thanks, I figured it out by blind luck just a few minutes earlier. Any idea why? On 2000.11.17, government thugs made [EMAIL PROTECTED] write: Flip it around, try % response.sendRedirect("bar.jsp"); response.addCookie(new Cookie("baz","quux")); % it seems like sendRedirect resets the HTTP headers.
Re: headers, cookies, redirect
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