tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kellan Elliott-McCrea" <kel...@anyday.com>
Subject Re: Redirect and cookies
Date Thu, 25 May 2000 16:33:23 GMT
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.

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
>


Mime
View raw message