Is there a problem with calling Response.sendRedirect() after Response.addCookie() ?

Alex Chaffee

Yes, there is a bug in Tomcat 3.1 (and possibly other servlet engines). To send a cookie through a redirect, you must set the headers manually. seanm@narus.com suggests:

        Cookie long_term = new Cookie(LONG_TERM_COOKIE_NAME, user_name);
        long_term.setMaxAge(60*60*24*4);
        long_term.setPath("/Blah");
        response.addCookie(long_term);

        response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
        response.setHeader("Location",REDIRECT_PAGE);
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact