You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "LOCHART,DOUGLAS E" <do...@cablespeed.com> on 2005/04/13 23:19:38 UTC

Logout question - Session Already Invalidated

I implemented the listener approach to logging out as 
reccomended by the FAQ on the Tapestry Wiki.  I used this 
approach to give the user an option to continue or to 
cancel out and to do some logging.

Occasionally I have received a ServletException "Session 
Already Invalidated".  I found a blurb somewhere on the 
net that mentioned do a restart like this:
  
public void logout(IRequestCycle cycle)
{
     IEngineServiceView engine = 
   (IEngineServiceView)getEngine();
     engine.restart();
}

in a listener is bad because the page will still render 
and could cause this exception.  However the responder did 
not give a clear alternative as to what to do.

So I again I must ask the Tapestry Gods ..... HELP

What is the best way to handle a logout CLEANLY that 
terminates the session?  

Please give an example if its not a simple one.

Thanks again to all,

Doug


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


Re: Logout question - Session Already Invalidated

Posted by Konstantin Iignatyev <kg...@yahoo.com>.
I would say there is a simple JSP way and it works well for me: a link 
to logoff.jsp that looks like this:
<%
  session.invalidate();
  response.sendRedirect( "app");
%>

Link:
<a href="logoff.jsp" class="menu" jwcid="logoff" >Log Off</a>

Component:
<component id="logoff" type="Any">
     <binding name="href" expression="page.engine.contextPath + 
'/logoff.jsp'"/>
  </component>

Vjeran Marcinko wrote:

>I just want to point out again to this problem, that should really have
>first-class support in any web framework due to it's commonality :
>http://issues.apache.org/jira/browse/TAPESTRY-237
>
>-Vjeran
>
>
>
>  
>


-- 
Thanks,

Konstantin Ignatyev

http://www.kgionline.com





PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2.700 tons of CFCs to the stratosphere, and increase their population by 263.000

Bowers, C.A.  The Culture of Denial:  
Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools.  
New York:  State University of New York Press, 1997: (4) (5) (p.206)


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


Re: Logout question - Session Already Invalidated

Posted by Vjeran Marcinko <vj...@tis.hr>.
----- Original Message ----- 
From: "Kent Tong" <ke...@cpttm.org.mo>
To: <ta...@jakarta.apache.org>
Sent: Friday, April 15, 2005 4:07 AM
Subject: Re: Logout question - Session Already Invalidated


> This is not a recommended way to terminate the session. You
> should not do it in a listener. You should do it only in
> a service. That's why the restart() method is only available
> in IEngineServiceView (the service's view on the engine).
>
> For the user to initiate the logout, use a ServiceLink
> component to invoke the restart service. For your internal
> logic to intiate the logout, throw a RedirectException
> to redirect to the restart service.

I just want to point out again to this problem, that should really have
first-class support in any web framework due to it's commonality :
http://issues.apache.org/jira/browse/TAPESTRY-237

-Vjeran



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.9 - Release Date: 13.4.2005


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


Re: Logout question - Session Already Invalidated

Posted by Kent Tong <ke...@cpttm.org.mo>.
LOCHART,DOUGLAS E <douglochart <at> cablespeed.com> writes:

> I wonder if the way I am doing it is causing a problem.
> 
> 	// This will invalidate the session
> 	IEngineServiceView engine = 
> (IEngineServiceView)cycle.getEngine();
> 	try {
> 	    logDebug("Calling RESTART");
> 	    engine.restart( cycle );
> 	}catch(IOException e) {
> 	    logError("Logout Exception:",e);
> 	}

This is not a recommended way to terminate the session. You
should not do it in a listener. You should do it only in
a service. That's why the restart() method is only available 
in IEngineServiceView (the service's view on the engine).

For the user to initiate the logout, use a ServiceLink
component to invoke the restart service. For your internal
logic to intiate the logout, throw a RedirectException
to redirect to the restart service.



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


Re: Logout question - Session Already Invalidated

Posted by Bryan Lewis <br...@maine.rr.com>.
Looks okay to me.  The engine you get from the cycle is the same one from
the page.  Checking the source... yes, the PageLoader takes the engine from
the cycle and attaches it to the page.


----- Original Message ----- 
From: "LOCHART,DOUGLAS E" <do...@cablespeed.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, April 13, 2005 10:44 PM
Subject: Re: Logout question - Session Already Invalidated


> Bryan,
>
> I wonder if the way I am doing it is causing a problem.
> My application can logout the user in two ways, the usual
> way (logout page) and internally based on application
> state.   (this is by design and required)  for whatever
> reason I have the logout logic in the Visit object.  It
> was like this:
>
> // This will invalidate the session
> IEngineServiceView engine =
> (IEngineServiceView)cycle.getEngine();
> try {
>     logDebug("Calling RESTART");
>     engine.restart( cycle );
> }catch(IOException e) {
>     logError("Logout Exception:",e);
> }
>
> ooh, never the mind, I noticed that I am catching only an
> IOException ...
>
> Anyway I was wondering if the way I am doing it is wrong?
> Does the cycle.getEngine() return the same engine instance
> as calling getEngine() in the page() ?
>
>
> thanks again
>
> Doug
>
> On Wed, 13 Apr 2005 20:15:59 -0400
>   "Bryan Lewis" <br...@maine.rr.com> wrote:
> >Oops, sorry about that.  It doesn't need to go in a
> >custom Engine class,
> >that's just where I put mine.  For trying it out you
> >could simply put the
> >method in your page class, like this:
> >
> >public void endSession(IRequestCycle cycle)
> >{
> >    try {
> >        getEngine().restart(cycle);
> >    }
> >    catch (Exception ex) {
> >        // Ignore it if the session was already
> >invalidated.
> >        log.debug(ex.getMessage());
> >    }
> >}
> >
> >
> >
> >----- Original Message ----- 
> >From: "LOCHART,DOUGLAS E" <do...@cablespeed.com>
> >To: "Tapestry users" <ta...@jakarta.apache.org>;
> >"Tapestry users"
> ><ta...@jakarta.apache.org>
> >Sent: Wednesday, April 13, 2005 6:44 PM
> >Subject: Re: Logout question - Session Already
> >Invalidated
> >
> >
> >> Bryan,
> >>
> >> Thanks.  I would ask one more thing.  I am still green
> >> (less than 2 months) and I have not attempted (or had
> >>the
> >> need to) write my own engine.  I do have the TIA book.
> >>  Could you tell me what engine you are talking about and
> >> point me to an example (either in the book or
> >>elsewhere).
> >> Thanks, I appreciate the help.
> >>
> >> I still would like to know what would cause this.
> >
> >
> >
> >---------------------------------------------------------------------
> >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: Logout question - Session Already Invalidated

Posted by "LOCHART,DOUGLAS E" <do...@cablespeed.com>.
Bryan,

I wonder if the way I am doing it is causing a problem.
My application can logout the user in two ways, the usual 
way (logout page) and internally based on application 
state.   (this is by design and required)  for whatever 
reason I have the logout logic in the Visit object.  It 
was like this:

	// This will invalidate the session
	IEngineServiceView engine = 
(IEngineServiceView)cycle.getEngine();
	try {
	    logDebug("Calling RESTART");
	    engine.restart( cycle );
	}catch(IOException e) {
	    logError("Logout Exception:",e);
	}

ooh, never the mind, I noticed that I am catching only an 
IOException ...

Anyway I was wondering if the way I am doing it is wrong?
Does the cycle.getEngine() return the same engine instance 
as calling getEngine() in the page() ?


thanks again

Doug

On Wed, 13 Apr 2005 20:15:59 -0400
  "Bryan Lewis" <br...@maine.rr.com> wrote:
>Oops, sorry about that.  It doesn't need to go in a 
>custom Engine class,
>that's just where I put mine.  For trying it out you 
>could simply put the
>method in your page class, like this:
>
>public void endSession(IRequestCycle cycle)
>{
>    try {
>        getEngine().restart(cycle);
>    }
>    catch (Exception ex) {
>        // Ignore it if the session was already 
>invalidated.
>        log.debug(ex.getMessage());
>    }
>}
>
>
>
>----- Original Message ----- 
>From: "LOCHART,DOUGLAS E" <do...@cablespeed.com>
>To: "Tapestry users" <ta...@jakarta.apache.org>; 
>"Tapestry users"
><ta...@jakarta.apache.org>
>Sent: Wednesday, April 13, 2005 6:44 PM
>Subject: Re: Logout question - Session Already 
>Invalidated
>
>
>> Bryan,
>>
>> Thanks.  I would ask one more thing.  I am still green
>> (less than 2 months) and I have not attempted (or had 
>>the
>> need to) write my own engine.  I do have the TIA book.
>>  Could you tell me what engine you are talking about and
>> point me to an example (either in the book or 
>>elsewhere).
>> Thanks, I appreciate the help.
>>
>> I still would like to know what would cause this.
>
>
>
>---------------------------------------------------------------------
>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: Logout question - Session Already Invalidated

Posted by Bryan Lewis <br...@maine.rr.com>.
Oops, sorry about that.  It doesn't need to go in a custom Engine class,
that's just where I put mine.  For trying it out you could simply put the
method in your page class, like this:

public void endSession(IRequestCycle cycle)
{
    try {
        getEngine().restart(cycle);
    }
    catch (Exception ex) {
        // Ignore it if the session was already invalidated.
        log.debug(ex.getMessage());
    }
}



----- Original Message ----- 
From: "LOCHART,DOUGLAS E" <do...@cablespeed.com>
To: "Tapestry users" <ta...@jakarta.apache.org>; "Tapestry users"
<ta...@jakarta.apache.org>
Sent: Wednesday, April 13, 2005 6:44 PM
Subject: Re: Logout question - Session Already Invalidated


> Bryan,
>
> Thanks.  I would ask one more thing.  I am still green
> (less than 2 months) and I have not attempted (or had the
> need to) write my own engine.  I do have the TIA book.
>  Could you tell me what engine you are talking about and
> point me to an example (either in the book or elsewhere).
> Thanks, I appreciate the help.
>
> I still would like to know what would cause this.



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


Re: Logout question - Session Already Invalidated

Posted by "LOCHART,DOUGLAS E" <do...@cablespeed.com>.
Bryan,

Thanks.  I would ask one more thing.  I am still green 
(less than 2 months) and I have not attempted (or had the 
need to) write my own engine.  I do have the TIA book. 
 Could you tell me what engine you are talking about and 
point me to an example (either in the book or elsewhere).
Thanks, I appreciate the help.

I still would like to know what would cause this.

Doug

On Wed, 13 Apr 2005 18:19:36 -0400
  "Bryan Lewis" <br...@maine.rr.com> wrote:
>I used to get that exception occasionally for reasons I 
>never quite
>understood.  Probably different ways of the session 
>ending, by logout or
>timeout or server restart...  Anyway, I ignored the 
>exception, figuring that
>if the invalidation was already done I didn't need to 
>repeat it.  I have
>this utility method in my Engine:
>
>    public void endSession(IRequestCycle cycle)
>    {
>        try {
>            restart(cycle);
>        }
>        catch (Exception ex) {
>            // Ignore it if the session was already 
>invalidated.
>            log.debug(ex.getMessage());
>        }
>    }
>
>I've been running like that for months with no bad 
>effects that I know of.
>Hmmm... looking back through my logs, I see that I'm not 
>getting the
>exception any more.  I must've cleaned up something else 
>since then.  Maybe
>that will get you started anyway... you can see when the 
>exception is
>occurring.
>
>I call that method from a simple form-listener method in 
>my login/logout
>component.
>
>
>
>----- Original Message ----- 
>From: "LOCHART,DOUGLAS E" <do...@cablespeed.com>
>To: <ta...@jakarta.apache.org>
>Sent: Wednesday, April 13, 2005 5:19 PM
>Subject: Logout question - Session Already Invalidated
>
>
>> I implemented the listener approach to logging out as
>> reccomended by the FAQ on the Tapestry Wiki.  I used 
>>this
>> approach to give the user an option to continue or to
>> cancel out and to do some logging.
>>
>> Occasionally I have received a ServletException "Session
>> Already Invalidated".  I found a blurb somewhere on the
>> net that mentioned do a restart like this:
>>
>> public void logout(IRequestCycle cycle)
>> {
>>      IEngineServiceView engine =
>>    (IEngineServiceView)getEngine();
>>      engine.restart();
>> }
>>
>> in a listener is bad because the page will still render
>> and could cause this exception.  However the responder 
>>did
>> not give a clear alternative as to what to do.
>>
>> So I again I must ask the Tapestry Gods ..... HELP
>>
>> What is the best way to handle a logout CLEANLY that
>> terminates the session?
>>
>> Please give an example if its not a simple one.
>>
>> Thanks again to all,
>>
>> Doug
>>
>>
>> ---------------------------------------------------------------------
>> 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: Logout question - Session Already Invalidated

Posted by Bryan Lewis <br...@maine.rr.com>.
I used to get that exception occasionally for reasons I never quite
understood.  Probably different ways of the session ending, by logout or
timeout or server restart...  Anyway, I ignored the exception, figuring that
if the invalidation was already done I didn't need to repeat it.  I have
this utility method in my Engine:

    public void endSession(IRequestCycle cycle)
    {
        try {
            restart(cycle);
        }
        catch (Exception ex) {
            // Ignore it if the session was already invalidated.
            log.debug(ex.getMessage());
        }
    }

I've been running like that for months with no bad effects that I know of.
Hmmm... looking back through my logs, I see that I'm not getting the
exception any more.  I must've cleaned up something else since then.  Maybe
that will get you started anyway... you can see when the exception is
occurring.

I call that method from a simple form-listener method in my login/logout
component.



----- Original Message ----- 
From: "LOCHART,DOUGLAS E" <do...@cablespeed.com>
To: <ta...@jakarta.apache.org>
Sent: Wednesday, April 13, 2005 5:19 PM
Subject: Logout question - Session Already Invalidated


> I implemented the listener approach to logging out as
> reccomended by the FAQ on the Tapestry Wiki.  I used this
> approach to give the user an option to continue or to
> cancel out and to do some logging.
>
> Occasionally I have received a ServletException "Session
> Already Invalidated".  I found a blurb somewhere on the
> net that mentioned do a restart like this:
>
> public void logout(IRequestCycle cycle)
> {
>      IEngineServiceView engine =
>    (IEngineServiceView)getEngine();
>      engine.restart();
> }
>
> in a listener is bad because the page will still render
> and could cause this exception.  However the responder did
> not give a clear alternative as to what to do.
>
> So I again I must ask the Tapestry Gods ..... HELP
>
> What is the best way to handle a logout CLEANLY that
> terminates the session?
>
> Please give an example if its not a simple one.
>
> Thanks again to all,
>
> Doug
>
>
> ---------------------------------------------------------------------
> 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