You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Craig Tataryn <cr...@tataryn.net> on 2008/10/14 06:00:33 UTC

newSession(...) being called for every request

Hi, I created a very simple little Wicket application which consisted
of one page and the page relied on session information which was to
persist between requests.  My surprise came when I found that
newSession(Request request, Response response)  on my WebApplication
class was being called for every request!  This is the first time I've
come across this, usually sessions "just work" the way I figure they
should (that is, stay around until they are expired).

In my investigation as to how to remedy this situation I came across
this list message:
http://www.nabble.com/Session-creation-td19123581.html#a19128690

So using "getSession().bind()" worked for me.

What exactly triggers Wicket to say "oh, I should keep sessions around
instead of creating them for every request".  Martijn seems to
indicate that if your pages are "statefull" then Sessions will
persist.  What is meant by "statefull"?  That they set stuff into the
session?  Or that they have member variables?

I noticed that bind() wasn't mentioned in WiA (first place I looked to
seek help)  Seems like it would have been an excellent callout item,
would have helped me anyway :)  Took me a while to find that mail list
posting, trying various search terms.

-- 
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
im: craiger316@hotmail.com, skype: craig.tataryn

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


Re: newSession(...) being called for every request

Posted by James Carman <ja...@carmanconsulting.com>.
I think Wicket could definitely benefit from a revamping of its online
documentation.  It would be nice to have a site similar to the way
Hibernate's is laid out.

On Tue, Oct 14, 2008 at 7:24 AM, jWeekend <jw...@cabouge.com> wrote:
>
> This does come up very often, including at our London Wicket Events and
> courses. Even the most advanced and experienced Wicket developers say things
> could be clearer in this area where information is not as plentiful and at
> such a high level of quality most other Wicket technical matters are usually
> documented at on the Wiki or in Wicket In Action, for example.
>
> There are snippets of helpful material but it is very scattered and usually
> in the context of some other Wicket feature rather than specifically about
> stateless vs stateful pages/components.
>
> http://cwiki.apache.org/WICKET/stateless-pages.html This wiki page  is a
> start, but something (clear definitions, reasons for stateless vs stateful,
> best practices etc) that the core devs can review and back would be
> reassuring.
>
> Regards - Cemal
> http://www.jWeekend.co.uk http://jWeekend.co.uk
>
>
>
>
> jwcarman wrote:
>>
>> Perhaps this one should go on an FAQ somewhere.  We see this question
>> quite often.
>>
>> On Tue, Oct 14, 2008 at 12:25 AM, Craig Tataryn <cr...@tataryn.net>
>> wrote:
>>> Yep, thanks Igor.
>>>
>>> On Mon, Oct 13, 2008 at 11:09 PM, Igor Vaynberg <ig...@gmail.com>
>>> wrote:
>>>> a stateless page in wicket means that the page does not need to be put
>>>> into
>>>> session. it can be reconstructed from scratch. such pages generally do
>>>> not
>>>> have stateful components (components that provide user with callbacks
>>>> such
>>>> as link and its onclick() or form and its onsubmit()).
>>>>
>>>> so until a stateful page is hit by the user wicket will not create an
>>>> http
>>>> session. this is an optimization for sites that want to scale out to
>>>> massive
>>>> amounts of users without requiring an http session.
>>>>
>>>> now since websession plays an important role in request cycle processing
>>>> and
>>>> is itself stored in http session we need to create a new instance on
>>>> every
>>>> request until we are able to reuse the instance by putting it into http
>>>> session.
>>>>
>>>> makes sense?
>>>>
>>>> -igor
>>>>
>>>> On Mon, Oct 13, 2008 at 9:00 PM, Craig Tataryn <cr...@tataryn.net>
>>>> wrote:
>>>>
>>>>> Hi, I created a very simple little Wicket application which consisted
>>>>> of one page and the page relied on session information which was to
>>>>> persist between requests.  My surprise came when I found that
>>>>> newSession(Request request, Response response)  on my WebApplication
>>>>> class was being called for every request!  This is the first time I've
>>>>> come across this, usually sessions "just work" the way I figure they
>>>>> should (that is, stay around until they are expired).
>>>>>
>>>>> In my investigation as to how to remedy this situation I came across
>>>>> this list message:
>>>>> http://www.nabble.com/Session-creation-td19123581.html#a19128690
>>>>>
>>>>> So using "getSession().bind()" worked for me.
>>>>>
>>>>> What exactly triggers Wicket to say "oh, I should keep sessions around
>>>>> instead of creating them for every request".  Martijn seems to
>>>>> indicate that if your pages are "statefull" then Sessions will
>>>>> persist.  What is meant by "statefull"?  That they set stuff into the
>>>>> session?  Or that they have member variables?
>>>>>
>>>>> I noticed that bind() wasn't mentioned in WiA (first place I looked to
>>>>> seek help)  Seems like it would have been an excellent callout item,
>>>>> would have helped me anyway :)  Took me a while to find that mail list
>>>>> posting, trying various search terms.
>>>>>
>>>>> --
>>>>> Craig Tataryn
>>>>> site: http://www.basementcoders.com/
>>>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Craig Tataryn
>>> site: http://www.basementcoders.com/
>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/newSession%28...%29-being-called-for-every-request-tp19966730p19971581.html
> Sent from the Wicket - User 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
>
>

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


Re: newSession(...) being called for every request

Posted by jWeekend <jw...@cabouge.com>.
This does come up very often, including at our London Wicket Events and
courses. Even the most advanced and experienced Wicket developers say things
could be clearer in this area where information is not as plentiful and at
such a high level of quality most other Wicket technical matters are usually
documented at on the Wiki or in Wicket In Action, for example. 

There are snippets of helpful material but it is very scattered and usually
in the context of some other Wicket feature rather than specifically about
stateless vs stateful pages/components. 

http://cwiki.apache.org/WICKET/stateless-pages.html This wiki page  is a
start, but something (clear definitions, reasons for stateless vs stateful,
best practices etc) that the core devs can review and back would be
reassuring.

Regards - Cemal
http://www.jWeekend.co.uk http://jWeekend.co.uk 




jwcarman wrote:
> 
> Perhaps this one should go on an FAQ somewhere.  We see this question
> quite often.
> 
> On Tue, Oct 14, 2008 at 12:25 AM, Craig Tataryn <cr...@tataryn.net>
> wrote:
>> Yep, thanks Igor.
>>
>> On Mon, Oct 13, 2008 at 11:09 PM, Igor Vaynberg <ig...@gmail.com>
>> wrote:
>>> a stateless page in wicket means that the page does not need to be put
>>> into
>>> session. it can be reconstructed from scratch. such pages generally do
>>> not
>>> have stateful components (components that provide user with callbacks
>>> such
>>> as link and its onclick() or form and its onsubmit()).
>>>
>>> so until a stateful page is hit by the user wicket will not create an
>>> http
>>> session. this is an optimization for sites that want to scale out to
>>> massive
>>> amounts of users without requiring an http session.
>>>
>>> now since websession plays an important role in request cycle processing
>>> and
>>> is itself stored in http session we need to create a new instance on
>>> every
>>> request until we are able to reuse the instance by putting it into http
>>> session.
>>>
>>> makes sense?
>>>
>>> -igor
>>>
>>> On Mon, Oct 13, 2008 at 9:00 PM, Craig Tataryn <cr...@tataryn.net>
>>> wrote:
>>>
>>>> Hi, I created a very simple little Wicket application which consisted
>>>> of one page and the page relied on session information which was to
>>>> persist between requests.  My surprise came when I found that
>>>> newSession(Request request, Response response)  on my WebApplication
>>>> class was being called for every request!  This is the first time I've
>>>> come across this, usually sessions "just work" the way I figure they
>>>> should (that is, stay around until they are expired).
>>>>
>>>> In my investigation as to how to remedy this situation I came across
>>>> this list message:
>>>> http://www.nabble.com/Session-creation-td19123581.html#a19128690
>>>>
>>>> So using "getSession().bind()" worked for me.
>>>>
>>>> What exactly triggers Wicket to say "oh, I should keep sessions around
>>>> instead of creating them for every request".  Martijn seems to
>>>> indicate that if your pages are "statefull" then Sessions will
>>>> persist.  What is meant by "statefull"?  That they set stuff into the
>>>> session?  Or that they have member variables?
>>>>
>>>> I noticed that bind() wasn't mentioned in WiA (first place I looked to
>>>> seek help)  Seems like it would have been an excellent callout item,
>>>> would have helped me anyway :)  Took me a while to find that mail list
>>>> posting, trying various search terms.
>>>>
>>>> --
>>>> Craig Tataryn
>>>> site: http://www.basementcoders.com/
>>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.feedburner.com/TheBasementCoders
>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>> im: craiger316@hotmail.com, skype: craig.tataryn
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/newSession%28...%29-being-called-for-every-request-tp19966730p19971581.html
Sent from the Wicket - User 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: newSession(...) being called for every request

Posted by James Carman <ja...@carmanconsulting.com>.
Perhaps this one should go on an FAQ somewhere.  We see this question
quite often.

On Tue, Oct 14, 2008 at 12:25 AM, Craig Tataryn <cr...@tataryn.net> wrote:
> Yep, thanks Igor.
>
> On Mon, Oct 13, 2008 at 11:09 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>> a stateless page in wicket means that the page does not need to be put into
>> session. it can be reconstructed from scratch. such pages generally do not
>> have stateful components (components that provide user with callbacks such
>> as link and its onclick() or form and its onsubmit()).
>>
>> so until a stateful page is hit by the user wicket will not create an http
>> session. this is an optimization for sites that want to scale out to massive
>> amounts of users without requiring an http session.
>>
>> now since websession plays an important role in request cycle processing and
>> is itself stored in http session we need to create a new instance on every
>> request until we are able to reuse the instance by putting it into http
>> session.
>>
>> makes sense?
>>
>> -igor
>>
>> On Mon, Oct 13, 2008 at 9:00 PM, Craig Tataryn <cr...@tataryn.net> wrote:
>>
>>> Hi, I created a very simple little Wicket application which consisted
>>> of one page and the page relied on session information which was to
>>> persist between requests.  My surprise came when I found that
>>> newSession(Request request, Response response)  on my WebApplication
>>> class was being called for every request!  This is the first time I've
>>> come across this, usually sessions "just work" the way I figure they
>>> should (that is, stay around until they are expired).
>>>
>>> In my investigation as to how to remedy this situation I came across
>>> this list message:
>>> http://www.nabble.com/Session-creation-td19123581.html#a19128690
>>>
>>> So using "getSession().bind()" worked for me.
>>>
>>> What exactly triggers Wicket to say "oh, I should keep sessions around
>>> instead of creating them for every request".  Martijn seems to
>>> indicate that if your pages are "statefull" then Sessions will
>>> persist.  What is meant by "statefull"?  That they set stuff into the
>>> session?  Or that they have member variables?
>>>
>>> I noticed that bind() wasn't mentioned in WiA (first place I looked to
>>> seek help)  Seems like it would have been an excellent callout item,
>>> would have helped me anyway :)  Took me a while to find that mail list
>>> posting, trying various search terms.
>>>
>>> --
>>> Craig Tataryn
>>> site: http://www.basementcoders.com/
>>> podcast:http://feeds.feedburner.com/TheBasementCoders
>>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>>> im: craiger316@hotmail.com, skype: craig.tataryn
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>
>
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> im: craiger316@hotmail.com, skype: craig.tataryn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: newSession(...) being called for every request

Posted by Craig Tataryn <cr...@tataryn.net>.
Yep, thanks Igor.

On Mon, Oct 13, 2008 at 11:09 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> a stateless page in wicket means that the page does not need to be put into
> session. it can be reconstructed from scratch. such pages generally do not
> have stateful components (components that provide user with callbacks such
> as link and its onclick() or form and its onsubmit()).
>
> so until a stateful page is hit by the user wicket will not create an http
> session. this is an optimization for sites that want to scale out to massive
> amounts of users without requiring an http session.
>
> now since websession plays an important role in request cycle processing and
> is itself stored in http session we need to create a new instance on every
> request until we are able to reuse the instance by putting it into http
> session.
>
> makes sense?
>
> -igor
>
> On Mon, Oct 13, 2008 at 9:00 PM, Craig Tataryn <cr...@tataryn.net> wrote:
>
>> Hi, I created a very simple little Wicket application which consisted
>> of one page and the page relied on session information which was to
>> persist between requests.  My surprise came when I found that
>> newSession(Request request, Response response)  on my WebApplication
>> class was being called for every request!  This is the first time I've
>> come across this, usually sessions "just work" the way I figure they
>> should (that is, stay around until they are expired).
>>
>> In my investigation as to how to remedy this situation I came across
>> this list message:
>> http://www.nabble.com/Session-creation-td19123581.html#a19128690
>>
>> So using "getSession().bind()" worked for me.
>>
>> What exactly triggers Wicket to say "oh, I should keep sessions around
>> instead of creating them for every request".  Martijn seems to
>> indicate that if your pages are "statefull" then Sessions will
>> persist.  What is meant by "statefull"?  That they set stuff into the
>> session?  Or that they have member variables?
>>
>> I noticed that bind() wasn't mentioned in WiA (first place I looked to
>> seek help)  Seems like it would have been an excellent callout item,
>> would have helped me anyway :)  Took me a while to find that mail list
>> posting, trying various search terms.
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.feedburner.com/TheBasementCoders
>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>> im: craiger316@hotmail.com, skype: craig.tataryn
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>



-- 
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
im: craiger316@hotmail.com, skype: craig.tataryn

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


Re: newSession(...) being called for every request

Posted by Igor Vaynberg <ig...@gmail.com>.
a stateless page in wicket means that the page does not need to be put into
session. it can be reconstructed from scratch. such pages generally do not
have stateful components (components that provide user with callbacks such
as link and its onclick() or form and its onsubmit()).

so until a stateful page is hit by the user wicket will not create an http
session. this is an optimization for sites that want to scale out to massive
amounts of users without requiring an http session.

now since websession plays an important role in request cycle processing and
is itself stored in http session we need to create a new instance on every
request until we are able to reuse the instance by putting it into http
session.

makes sense?

-igor

On Mon, Oct 13, 2008 at 9:00 PM, Craig Tataryn <cr...@tataryn.net> wrote:

> Hi, I created a very simple little Wicket application which consisted
> of one page and the page relied on session information which was to
> persist between requests.  My surprise came when I found that
> newSession(Request request, Response response)  on my WebApplication
> class was being called for every request!  This is the first time I've
> come across this, usually sessions "just work" the way I figure they
> should (that is, stay around until they are expired).
>
> In my investigation as to how to remedy this situation I came across
> this list message:
> http://www.nabble.com/Session-creation-td19123581.html#a19128690
>
> So using "getSession().bind()" worked for me.
>
> What exactly triggers Wicket to say "oh, I should keep sessions around
> instead of creating them for every request".  Martijn seems to
> indicate that if your pages are "statefull" then Sessions will
> persist.  What is meant by "statefull"?  That they set stuff into the
> session?  Or that they have member variables?
>
> I noticed that bind() wasn't mentioned in WiA (first place I looked to
> seek help)  Seems like it would have been an excellent callout item,
> would have helped me anyway :)  Took me a while to find that mail list
> posting, trying various search terms.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> im: craiger316@hotmail.com, skype: craig.tataryn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>