tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manea Mirko <m...@arena.sci.univr.it>
Subject Re: Redirect and cookies
Date Thu, 25 May 2000 17:34:02 GMT
On Thu, May 25, 2000 at 12:33:23PM -0400, Kellan Elliott-McCrea wrote:
> I use Resin instead of Tomcat so I'm not actually sure how Tomcat works.
> 
> However according to the Servlet 2.2 spec <jsp:forward page="...">, and
> RequestDispatcher.forward will both clear the response buffer before
> forwarding control.  Which means the ONLY way to set a cookie is to use
> sendRedirect.

Thank you very much for your reply. I've just installed resin and my snippet
of code works. Is this a tomcat bug ?

> 
> Kellan
> 
> > I had the same problem... Use <jsp:forward page="...">, not sendRedirect !
> Ok ?
> >
> >
> > Luiz
> >
> >
> > Em qua, 24 mai 2000, you wrote:
> > > Hi,
> > >
> > >    switching from jserv 1.1 to tomcat 3.1 I found that the following
> snippet
> > > of code doesn't work any more:
> > >
> > > String name = "foo";
> > > String value = "admin";
> > > if (name != null && name.length() > 0) {
> > >     Cookie c = new Cookie(name, value);
> > >     c.setMaxAge(4*60*60);
> > >     c.setVersion(0);
> > >     c.setPath("/");
> > >     response.addCookie(c);
> > >
> response.sendRedirect(response.encodeRedirectURL("http://www.mysite.com"));
> > > }
> > >
> > > The problem is that if I try to set a cookie and then call
> > > response.sendRedirect, the cookie is not set at all.
> > > If I comment out the last line of code, the cookie is set.
> > > Is this a tomcat problem ? With jserv 1.1 this code worked fine.
> > >
> > > Thanks very much,
> > > Mirko Manea
> > >
> >
> > --------------------------------------------------------------------------
> > > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > > For additional commmands, email: tomcat-user-help@jakarta.apache.org
> > --
> > Luiz Borba
> > Diga-me.com
> >
> >
> > --------------------------------------------------------------------------
> > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commmands, email: tomcat-user-help@jakarta.apache.org
> >
> 
> 
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org

-- 
Best Regards,
      Mirko Manea

Mime
View raw message