tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ALEXANDROS KOTSIRAS" <ALEXANDRO...@prodigy.net>
Subject Re: response.addCookie() problem
Date Tue, 08 Aug 2000 04:55:56 GMT
It has been discused before  and if i remember well there is a trick ,
instead of forwarding/redirecting  set a request Header like
...MOVED_TEMPORARY or something
and then set the LOCATION header to the forwrding page
and ....another couple of lines that i don't recall.

Probably in the mailing-list archives you can search and find the exact
answer.


----- Original Message -----
From: Mason Jones <mason@clipshow.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Monday, August 07, 2000 6:54 PM
Subject: response.addCookie() problem


>
> Hello, all... I'm doing something pretty straightforward, trying
> to add a cookie to a servlet response before doing a redirect
> to a jsp page. But the cookie's simply not being set. Hope
> someone can steer me in the right direction to figure out why
> it's not happening... Here's the code:
>
> String cookiestr = "Testing cookies";
> Cookie uc = new Cookie("MYTEST", cookiestr);
> uc.setDomain("www.clipshow.com");
> uc.setMaxAge(60 * 60 * 24 * 365);
> response.addCookie(uc);
>
> This is in a method which is called, passing in the response
> object. Then the code does a forward call:
>
> RequestDispatcher rd =
>                getServletContext().getRequestDispatcher(url);
> rd.forward(request, response);
>
> When I hit this servlet, it does the forward correctly, but when
> I then go check my cookies, the MYTEST cookie is not set.
> Is there anything about the forward that might cause the response
> to not be sent out, and hence the cookie isn't set? Although I've
> tried doing a normal sendRedirect() and the cookie still doesn't
> seem to be set...
>
> Thanks for any help.
>
>
> ________________________________________
>    Mason Jones              mason(at)clipshow.com
>    Director of Software Development
>    ClipShow, Inc.            www.clipshow.com
>    (650) 696-3164           fax (650) 696-3267
>


Mime
View raw message