On 10/22/13 15:32, Martin Grigorov wrote:
> On Tue, Oct 22, 2013 at 4:27 PM, Joachim Schrod <jsch...@acm.org> wrote:
> 
>> On 10/22/13 10:34, christoph.ma...@t-systems.com wrote:
>> > If I do this in my WicketApplication class, in the init()
>> > method I get java.lang.reflect.UndeclaredThrowableException.
>> > But if I add this to my base page it works. Is there any
>> > possibility to do this in the WicketApplication class?
>>
>> You have to redefine WebApplication#newSession().
>>
>> It can't be done in init(), as no session exists yet. And you must
>> set the Session timeout for each new session anew.
>>
>> Without having tried it, code like
>>
>>     @Override
>>     public Session newSession(Request request, Response response) {
>>         Session session = super.newSession(request, response);
>>
>>
>> ((ServletWebRequest)request).getContainerRequest().getSession().setMaxInactiveInterval(TIMEOUT);
>>
> 
> ALARM!
> getSession() is the same as getSession(true). I.e. it will create a new
> http session for each and every http request, even for static resources.
> 
> Wicket creates Wicket Session when Session.get() is used, but creates Http
> Session only when wicketSession.bind() is called.

Interesting to hear; I'd have thought that works. Tricky thing,
that. As I wrote, I didn't try the code; I just copied the access
to HttpSession from the posts below.

But, since wicketSession.bind() is final, one cannot subclass
Session and redefine it either, to set the timeout there. (Much too
many methods of Wicket classes are final, without really good
reason; I copy them to my applications making the methods non-final
much too often. :-( )

Martin, what would you propose to be the hook that allows to
establish a different session timeout application-wide within your
Java application? I hadn't had yet that case, web.xml suffices by
now, but it would be good to know for the future.

Cheers,
        Joachim

>>         return session;
>>     }
>>
>> should work. Maybe check that request is really a
>> ServletWebRequest. (This is also a good place to set the locale.)
>>
>> HTH,
>>         Joachim
>>
>> >
>> > -----Ursprüngliche Nachricht-----
>> > Von: francois meillet [mailto:francois.meil...@gmail.com]
>> > Gesendet: Montag, 21. Oktober 2013 16:34
>> > An: users@wicket.apache.org
>> > Betreff: Re: set session-timeout
>> >
>> > HttpSession httpSession = ((ServletWebRequest)
>> RequestCycle.get().getRequest()).getContainerRequest().getSession();
>> > httpSession.setMaxInactiveInterval(timeOut);
>> >
>> > François
>> >
>> >
>> > On Mon, Oct 21, 2013 at 4:12 PM, Martin Grigorov <mgrigo...@apache.org
>> >wrote:
>> >
>> >>
>> >> http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.6/a
>> >> pi/javax/servlet/http/HttpSession.html#setMaxInactiveInterval(int)
>> >>
>> >>
>> >> On Mon, Oct 21, 2013 at 4:44 PM, <christoph.ma...@t-systems.com> wrote:
>> >>
>> >> > Hello,
>> >> >
>> >> > in my application i have set the errorpage for expired pages like
>> this:
>> >> >
>> >> > getApplicationSettings().setPageExpiredErrorPage(Timeout.class);
>> >> >
>> >> > Now I want to make the time until the application expires
>> configurable.
>> >> > How can I do this? Can I set this in the WicketApplication.init()?
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod, Roedermark, Germany
Email: jsch...@acm.org


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

Reply via email to