You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Klaus Kopruch <kl...@materna.de> on 2010/01/15 15:25:16 UTC

Handling session expiry

Hello,

can someone pls give me some hints how to handle user session expirations
without writing much boilerplate code? I'd like to send a special session
expiry page. Has T5 a mechanism for that?

Thx, Klaus
-- 
View this message in context: http://old.nabble.com/Handling-session-expiry-tp27177262p27177262.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Handling session expiry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 15 Jan 2010 13:08:50 -0200, Klaus Kopruch  
<kl...@materna.de> wrote:

> In javax.servlet.http.HttpSession or  
> org.apache.tapestry5.services.Session?

Tapestry's Session is just a facade around the HttpSession. Thus, setting  
some attribute in Session makes it be set in the HttpSession too.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: Handling session expiry

Posted by Klaus Kopruch <kl...@materna.de>.

Thiago H. de Paula Figueiredo wrote:
> 
> I don't use @SessionState with my HttpSessionBindingListener  
> implementation. I set it in the Session directly. ;)
> 

In javax.servlet.http.HttpSession or org.apache.tapestry5.services.Session?
-- 
View this message in context: http://old.nabble.com/Handling-session-expiry-tp27177262p27178554.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Handling session expiry

Posted by Klaus Kopruch <kl...@materna.de>.
Ah, thanks!


Massimo Lusetti wrote:
> 
>>
>> Thanks a lot!
>>
>> How can I access a T5 service from sessionDestroyed() ?
> 
> As i said from my first reply get the Registry from the
> ServletContext, it is stored there under
> TapestryFilter.REGISTRY_CONTEXT_NAME
> 

-- 
View this message in context: http://old.nabble.com/Handling-session-expiry-tp27177262p27223034.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Handling session expiry

Posted by Massimo Lusetti <ml...@gmail.com>.
On Tue, Jan 19, 2010 at 10:15 AM, Klaus Kopruch
<kl...@materna.de> wrote:

>
> Thanks a lot!
>
> How can I access a T5 service from sessionDestroyed() ?

As i said from my first reply get the Registry from the
ServletContext, it is stored there under
TapestryFilter.REGISTRY_CONTEXT_NAME

Cheers
-- 
Massimo
http://meridio.blogspot.com

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


Re: Handling session expiry

Posted by Klaus Kopruch <kl...@materna.de>.
Thanks a lot!

How can I access a T5 service from sessionDestroyed() ?


P.Stavrinides wrote:
> 
> Exactly, just set it in your web.xml:
> 
>   <listener-class>
> 			com.web.application.SessionListener
> 		</listener-class>
> 
> And then in SessionListener:
> 
> /** @see HttpSessionListener#sessionCreated(HttpSessionEvent) */
> 	public void sessionCreated(HttpSessionEvent event) {
> 		Logger.getLogger(getClass()).info(
> 					"Session created with id: " + event.getSession().getId());
> 	}
> 
> 	/** @see HttpSessionListener#sessionDestroyed(HttpSessionEvent) */
> 	public void sessionDestroyed(HttpSessionEvent event) {
>           //your logic here
>        }
> 
> 
> and bobs your uncle!
> Peter
> 

-- 
View this message in context: http://old.nabble.com/Handling-session-expiry-tp27177262p27222811.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Handling session expiry

Posted by Peter Stavrinides <P....@albourne.com>.
> I don't use @SessionState with my HttpSessionBindingListener  
> implementation. I set it in the Session directly. ;)

Exactly, just set it in your web.xml:

  <listener-class>
			com.web.application.SessionListener
		</listener-class>

And then in SessionListener:

/** @see HttpSessionListener#sessionCreated(HttpSessionEvent) */
	public void sessionCreated(HttpSessionEvent event) {
		Logger.getLogger(getClass()).info(
					"Session created with id: " + event.getSession().getId());
	}

	/** @see HttpSessionListener#sessionDestroyed(HttpSessionEvent) */
	public void sessionDestroyed(HttpSessionEvent event) {
          //your logic here
       }


and bobs your uncle!
Peter

-- 
If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Please visit http://www.albourne.com/email.html for important additional terms relating to this e-mail.

----- Original Message -----
From: "Thiago H. de Paula Figueiredo" <th...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Friday, 15 January, 2010 16:44:28 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Handling session expiry

On Fri, 15 Jan 2010 12:40:24 -0200, Massimo Lusetti <ml...@gmail.com>  
wrote:

> On Fri, Jan 15, 2010 at 3:34 PM, Thiago H. de Paula Figueiredo
> <th...@gmail.com> wrote:
>
>> T5 doesn't, but the Servlet API has. Create an  
>> HttpSessionBindingListener
>> implementation and add it to the Session. Its valueUnbound() method  
>> will be
>> invoked when the session is invalidated.
>
> Actually HttpSessionBindingListener.valueUnbound() Notifies the object
> that it is being unbound from a session and identifies the session, so
> due to the way T5 use the session with @SessionState object I would
> play carefully with it :)

I don't use @SessionState with my HttpSessionBindingListener  
implementation. I set it in the Session directly. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


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


Re: Handling session expiry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 15 Jan 2010 12:40:24 -0200, Massimo Lusetti <ml...@gmail.com>  
wrote:

> On Fri, Jan 15, 2010 at 3:34 PM, Thiago H. de Paula Figueiredo
> <th...@gmail.com> wrote:
>
>> T5 doesn't, but the Servlet API has. Create an  
>> HttpSessionBindingListener
>> implementation and add it to the Session. Its valueUnbound() method  
>> will be
>> invoked when the session is invalidated.
>
> Actually HttpSessionBindingListener.valueUnbound() Notifies the object
> that it is being unbound from a session and identifies the session, so
> due to the way T5 use the session with @SessionState object I would
> play carefully with it :)

I don't use @SessionState with my HttpSessionBindingListener  
implementation. I set it in the Session directly. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: Handling session expiry

Posted by Klaus Kopruch <kl...@materna.de>.
Tx, I'll play with it.
-- 
View this message in context: http://old.nabble.com/Handling-session-expiry-tp27177262p27178359.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Handling session expiry

Posted by Massimo Lusetti <ml...@gmail.com>.
On Fri, Jan 15, 2010 at 3:34 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:

> T5 doesn't, but the Servlet API has. Create an HttpSessionBindingListener
> implementation and add it to the Session. Its valueUnbound() method will be
> invoked when the session is invalidated.

Actually HttpSessionBindingListener.valueUnbound() Notifies the object
that it is being unbound from a session and identifies the session, so
due to the way T5 use the session with @SessionState object I would
play carefully with it :)

Cheers
-- 
Massimo
http://meridio.blogspot.com

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


Re: Handling session expiry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 15 Jan 2010 12:25:16 -0200, Klaus Kopruch  
<kl...@materna.de> wrote:

> Hello,

Hi!

> can someone pls give me some hints how to handle user session expirations
> without writing much boilerplate code? I'd like to send a special session
> expiry page. Has T5 a mechanism for that?

T5 doesn't, but the Servlet API has. Create an HttpSessionBindingListener  
implementation and add it to the Session. Its valueUnbound() method will  
be invoked when the session is invalidated.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: Handling session expiry

Posted by Klaus Kopruch <kl...@materna.de>.

Massimo Lusetti wrote:
> 
> Implement one of the listeners, for ex HttpSessionListener, then
> access the registry from the context and do what you need.
> 

Where do you install HttpSessionListener? What registry and what context do
you mean?
-- 
View this message in context: http://old.nabble.com/Handling-session-expiry-tp27177262p27178413.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Handling session expiry

Posted by Massimo Lusetti <ml...@gmail.com>.
On Fri, Jan 15, 2010 at 3:25 PM, Klaus Kopruch <kl...@materna.de> wrote:

> can someone pls give me some hints how to handle user session expirations
> without writing much boilerplate code? I'd like to send a special session
> expiry page. Has T5 a mechanism for that?

Implement one of the listeners, for ex HttpSessionListener, then
access the registry from the context and do what you need.

Cheers
-- 
Massimo
http://meridio.blogspot.com

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