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/03/31 15:48:54 UTC

Best way to implement a logout link

In my old struts based web apps i had an action that just simply 
invalidated the session then returned to the home page
and then the home page checked for a vaild session and if there wasn't 
one it went to the login page

what is the best way to do this in tapestry

i have a home page that extends a protected page which throws a 
pageredirectionexception to the login page when the visit object 
does'nt pass my login details i.e username is null so in tapestry how 
do i invalidate the session and return to the home page which should 
redirect to the login page

Cheers

Stephen


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


Re: Best way to implement a logout link

Posted by Bryan Lewis <br...@maine.rr.com>.
There have been a couple of discussions of this in the past.  Here's
what's working for me, based on those discussions.  It might be doing a
bit more work than absolutely necessary.

    public void logout(IRequestCycle cycle)
    {
        // Drop the user's visit object.
        IEngine engine = getEngine();
        Map visit = (Map) engine.getVisit();
        engine.setVisit(null);

        try {
            HttpSession session =
cycle.getRequestContext().getSession();
            if (session != null) {
                session.invalidate();
            }
        } catch (IllegalStateException ex) { }

        cycle.activate("Home");
    }

This shorter version might also work for you; engine.restart()
invalidates the session.

            try {
                ((AbstractEngine) getPage().getEngine()).restart(cycle);
            }
            catch (Exception e) { }



----- Original Message ----- 
From: "stephen smithstone" <sk...@lchost.co.uk>
To: "Tapestry List" <ta...@jakarta.apache.org>
Sent: Wednesday, March 31, 2004 8:48 AM
Subject: Best way to implement a logout link


> In my old struts based web apps i had an action that just simply
> invalidated the session then returned to the home page
> and then the home page checked for a vaild session and if there wasn't
> one it went to the login page
>
> what is the best way to do this in tapestry
>
> i have a home page that extends a protected page which throws a
> pageredirectionexception to the login page when the visit object
> does'nt pass my login details i.e username is null so in tapestry how
> do i invalidate the session and return to the home page which should
> redirect to the login page
>
> Cheers
>
> Stephen
>
>
> ---------------------------------------------------------------------
> 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