You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kamiseq <ka...@gmail.com> on 2011/11/17 00:52:17 UTC

wicket 1.5.3 problems with cookies

hej,
it seems that wicket is not storing cookies :/.

im adding TEST cookie with

final Cookie cookie = new Cookie(name, value);
cookie.setMaxAge(Integer.MAX_VALUE);
((WebResponse)getResponse()).addCookie(cookie);

and reading it on different page

final List<Cookie> cookies = ((WebRequest) getRequest()).getCookies();
Cookie result = null;
for (Cookie cookie : cookies)
{
    final String name = cookie.getName();
    log.fine("checking cookie name="+ name);
    if (name.equals(cookieName))
        result = cookie;
}
return result;

but only
checking cookie name=JSESSIONID is logged

this is very odd :/ any ideas?

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: wicket 1.5.3 problems with cookies

Posted by kamiseq <ka...@gmail.com>.
hej,
so I tired CookieUtils and still cookies are not persisted.

I ve checked it both on GAE and jetty

I can try setup fresh wicket and check it there but it just strange

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: wicket 1.5.3 problems with cookies

Posted by kamiseq <ka...@gmail.com>.
hi martin,
so yes previously I had a problem with unit tests when I was setting
cookie and redirecting with throw new RestartResponseException(new
MyOtherPage());
then you advised to used NonResettingRestartException but this for
some reason (I had no time yet to investigate) is breaking unittest so
now I am using setResponsePage(pageClass);

now I try to test it live with jetty and gae and for both servers it
is failing. (to redirect I use setResponsePage)

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket 1.5.3 problems with cookies

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Nov 17, 2011 at 8:54 AM, Dirk Forchel <di...@exedio.com> wrote:
> Why is it important not to use RestartResponseException? In Wicket 1.4 it was
> the preferred way to redirect to another (error) page e.g. in case of a
> missing resource during construction time of a page.

1) response.addCookie(cookie)
2) reset the response
3) no cookies in this response anymore

I'm not saying to not use RestartResponseException at all. I'm just
saying that it will lose any headers you set to the current response
so far.

>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-1-5-3-problems-with-cookies-tp4078351p4079137.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket 1.5.3 problems with cookies

Posted by Dirk Forchel <di...@exedio.com>.
Why is it important not to use RestartResponseException? In Wicket 1.4 it was
the preferred way to redirect to another (error) page e.g. in case of a
missing resource during construction time of a page.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-1-5-3-problems-with-cookies-tp4078351p4079137.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket 1.5.3 problems with cookies

Posted by Martin Grigorov <mg...@apache.org>.
See CookieUtils helper class
and make sure that you don't use ResetResponseException or any of its
specializations like RestartResponseException

On Thu, Nov 17, 2011 at 1:52 AM, kamiseq <ka...@gmail.com> wrote:
> hej,
> it seems that wicket is not storing cookies :/.
>
> im adding TEST cookie with
>
> final Cookie cookie = new Cookie(name, value);
> cookie.setMaxAge(Integer.MAX_VALUE);
> ((WebResponse)getResponse()).addCookie(cookie);
>
> and reading it on different page
>
> final List<Cookie> cookies = ((WebRequest) getRequest()).getCookies();
> Cookie result = null;
> for (Cookie cookie : cookies)
> {
>    final String name = cookie.getName();
>    log.fine("checking cookie name="+ name);
>    if (name.equals(cookieName))
>        result = cookie;
> }
> return result;
>
> but only
> checking cookie name=JSESSIONID is logged
>
> this is very odd :/ any ideas?
>
> pozdrawiam
> Paweł Kamiński
>
> kamiseq@gmail.com
> pkaminski.prv@gmail.com
> ______________________
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org