You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by stephen smithstone <sk...@lchost.co.uk> on 2004/04/01 18:11:38 UTC

Listening for expiring sessions

is there any tapestry object / method that gets notified when a session 
has expired

Stephen


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


Re[2]: Listening for expiring sessions

Posted by "Dmitry I. Zubarovsky" <au...@rambler.ru>.
Hello stephen,

That happens when IEngineService generates stalesession exception or
user generates it.

Concerning implementing session listener ,
you need to specify listener class in web.xml file

Dima

ss> that only happens when the a user generates a stalesession correct?

ss> what i need to do is listen to when the container sends a 
ss> HttpSessionEvent i.e in the HttpSessionListener interface there is a 
ss> method sessionDestroyed( HttpSessionEvent ev ) that gets notified when 
ss> a session expires

ss> i tried extending ApplicationServlet and implmenting the 
ss> HttpSessionListener with some simple system.out 's when a session is 
ss> created / destroyed , how ever they never get notified

ss> On 1 Apr 2004, at 17:21, Dmitry I. Zubarovsky wrote:

>> Hello stephen!
>>
>> you can override handleStaleSessionException method in your Engine
>> for example
>>
>>  protected void handleStaleSessionException(StaleSessionException 
>> p_pStaleSessionException,
>>                                                IRequestCycle         
>> p_pRequestCycle,
>>                                                ResponseOutputStream  
>> p_pOstreamReponse)
>>         throws IOException,ServletException {
>>         
>> redirect(CConstants.HOME_PAGE_KEY,p_pRequestCycle,p_pOstreamReponse,
>>                  p_pStaleSessionException);
>>     }
>> Regards,
>> Dima
>>
>>
>> ss> is there any tapestry object / method that gets notified when a 
>> session
>> ss> has expired
>>
>> ss> Stephen
>>
>>
>> ss> 
>> ---------------------------------------------------------------------
>> ss> To unsubscribe, e-mail: 
>> tapestry-user-unsubscribe@jakarta.apache.org
>> ss> For additional commands, e-mail: 
>> tapestry-user-help@jakarta.apache.org
>>
>>
>>
>> -- 
>> Best regards,
>>  Dmitry                            mailto:aurox@rambler.ru
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>


ss> ---------------------------------------------------------------------
ss> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
ss> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



-- 
Best regards,
 Dmitry                            mailto:aurox@rambler.ru


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


Re: Listening for expiring sessions

Posted by stephen smithstone <sk...@lchost.co.uk>.
my fault i implemented the interface but didn't register the listener


On 1 Apr 2004, at 17:31, stephen smithstone wrote:

> that only happens when the a user generates a stalesession correct?
>
> what i need to do is listen to when the container sends a 
> HttpSessionEvent i.e in the HttpSessionListener interface there is a 
> method sessionDestroyed( HttpSessionEvent ev ) that gets notified when 
> a session expires
>
> i tried extending ApplicationServlet and implmenting the 
> HttpSessionListener with some simple system.out 's when a session is 
> created / destroyed , how ever they never get notified
>
> On 1 Apr 2004, at 17:21, Dmitry I. Zubarovsky wrote:
>
>> Hello stephen!
>>
>> you can override handleStaleSessionException method in your Engine
>> for example
>>
>>  protected void handleStaleSessionException(StaleSessionException 
>> p_pStaleSessionException,
>>                                                IRequestCycle         
>> p_pRequestCycle,
>>                                                ResponseOutputStream  
>> p_pOstreamReponse)
>>         throws IOException,ServletException {
>>         
>> redirect(CConstants.HOME_PAGE_KEY,p_pRequestCycle,p_pOstreamReponse,
>>                  p_pStaleSessionException);
>>     }
>> Regards,
>> Dima
>>
>>
>> ss> is there any tapestry object / method that gets notified when a 
>> session
>> ss> has expired
>>
>> ss> Stephen
>>
>>
>> ss> 
>> ---------------------------------------------------------------------
>> ss> To unsubscribe, e-mail: 
>> tapestry-user-unsubscribe@jakarta.apache.org
>> ss> For additional commands, e-mail: 
>> tapestry-user-help@jakarta.apache.org
>>
>>
>>
>> -- 
>> Best regards,
>>  Dmitry                            mailto:aurox@rambler.ru
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Listening for expiring sessions

Posted by stephen smithstone <sk...@lchost.co.uk>.
that only happens when the a user generates a stalesession correct?

what i need to do is listen to when the container sends a 
HttpSessionEvent i.e in the HttpSessionListener interface there is a 
method sessionDestroyed( HttpSessionEvent ev ) that gets notified when 
a session expires

i tried extending ApplicationServlet and implmenting the 
HttpSessionListener with some simple system.out 's when a session is 
created / destroyed , how ever they never get notified

On 1 Apr 2004, at 17:21, Dmitry I. Zubarovsky wrote:

> Hello stephen!
>
> you can override handleStaleSessionException method in your Engine
> for example
>
>  protected void handleStaleSessionException(StaleSessionException 
> p_pStaleSessionException,
>                                                IRequestCycle         
> p_pRequestCycle,
>                                                ResponseOutputStream  
> p_pOstreamReponse)
>         throws IOException,ServletException {
>         
> redirect(CConstants.HOME_PAGE_KEY,p_pRequestCycle,p_pOstreamReponse,
>                  p_pStaleSessionException);
>     }
> Regards,
> Dima
>
>
> ss> is there any tapestry object / method that gets notified when a 
> session
> ss> has expired
>
> ss> Stephen
>
>
> ss> 
> ---------------------------------------------------------------------
> ss> To unsubscribe, e-mail: 
> tapestry-user-unsubscribe@jakarta.apache.org
> ss> For additional commands, e-mail: 
> tapestry-user-help@jakarta.apache.org
>
>
>
> -- 
> Best regards,
>  Dmitry                            mailto:aurox@rambler.ru
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Listening for expiring sessions

Posted by "Dmitry I. Zubarovsky" <au...@rambler.ru>.
Hello stephen!

you can override handleStaleSessionException method in your Engine
for example

 protected void handleStaleSessionException(StaleSessionException p_pStaleSessionException,
                                               IRequestCycle         p_pRequestCycle,
                                               ResponseOutputStream  p_pOstreamReponse)
        throws IOException,ServletException {
        redirect(CConstants.HOME_PAGE_KEY,p_pRequestCycle,p_pOstreamReponse,
                 p_pStaleSessionException);
    }
Regards,
Dima


ss> is there any tapestry object / method that gets notified when a session 
ss> has expired

ss> Stephen


ss> ---------------------------------------------------------------------
ss> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
ss> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



-- 
Best regards,
 Dmitry                            mailto:aurox@rambler.ru


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


Re: Listening for expiring sessions

Posted by Darren Foltinek <da...@frontrange.ca>.
>is there any tapestry object / method that gets notified when a session 
>has expired

Not that we could find, but we dealt with using the attached code, which 
checks to see if the EXISTING visit object is NULL - note that you can't 
just call page.getVisit().

-- Darren


  public void pageValidate (PageEvent event) {
       Visit visit = null;
       boolean sessionTimeout = false;

       /**
        * Find out if the Visit object has been created.
        * The default page.getVisit() method will create one if needed.
        **/
       if( event != null ) {
         IRequestCycle cycle = event.getRequestCycle();
         if( cycle != null ) {
           IEngine engine = cycle.getEngine();
           if( engine != null ) {
             visit = (Visit) engine.getVisit ();
             if( visit == null ) {
               sessionTimeout = true;;
             }
           } else {
             debug(method, "Engine was NULL");
           }
         } else {
           debug(method, "Cycle was NULL");
         }
       } else {
         debug(method, "Event was NULL");
       }

       if( sessionTimeout ) {
         // Timed out or came from external page.
         debug (method, "\n***** SESSION TIMED OUT *****\n");
         throw new StaleSessionException ("Your session has timed out.", 
getPage ());
      }
}


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