You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Haselbach <ch...@tngtech.com> on 2006/05/23 16:53:54 UTC

Invalidate session

Hello,

how can a session be invalidadted gracefully? Simply calling
session.invalidate() (where session for example was retrieved using
WebRequest.getSession()) does invalidate exception, but will result
in an exception later on in AbstractEngine. Here, the state manager
is flushed which will complain about the missing session.

The exception is catched by AbstractEngine. But an error is logged.

Any ideas? Thanks.

Regards,
Christian

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


Re: Invalidate session

Posted by Stephane Decleire <sd...@cariboo-networks.com>.
There's a very good sample developped by Howard in the Vlib sample 
bundled with Tapestry ...

Christian Haselbach wrote:

>Quoting Bryan Lewis <br...@maine.rr.com>:
>
>  
>
>>This has been discussed a few times before.  For example,
>>    
>>
>
>Yes, I have googled a bit and found some small discussions. But
>they were not to helpful.
>
>  
>
>>As you say, Tapestry doesn't allow the exception to bubble up to the
>>user, but it does put a worrisome stack trace in the log.  The Tapestry
>>developers weren't highly motivated to fix this minor annoyance :-)  so
>>    
>>
>
>Well, it is more than an annoyance when you deploy in Tomcat 5.5.15,
>where the exception reporter gets a null pointer exception from the
>session.getID(). The user will get a tomcat error report and not the
>logout page.
>
>  
>
>>I just ignored it for a while, and then worked around it in my custom
>>Engine. It's not pretty but hey, it's a work-around.
>>    
>>
>
>Thanks.
>
>Regards,
>Christian
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>For additional commands, e-mail: users-help@tapestry.apache.org
>
>  
>

-- 
Stéphane Decleire

05 56 57 99 20
06 63 78 69 06


Re: Invalidate session

Posted by Christian Haselbach <ch...@tngtech.com>.
Quoting Bryan Lewis <br...@maine.rr.com>:

> This has been discussed a few times before.  For example,

Yes, I have googled a bit and found some small discussions. But
they were not to helpful.

> As you say, Tapestry doesn't allow the exception to bubble up to the
> user, but it does put a worrisome stack trace in the log.  The Tapestry
> developers weren't highly motivated to fix this minor annoyance :-)  so

Well, it is more than an annoyance when you deploy in Tomcat 5.5.15,
where the exception reporter gets a null pointer exception from the
session.getID(). The user will get a tomcat error report and not the
logout page.

> I just ignored it for a while, and then worked around it in my custom
> Engine. It's not pretty but hey, it's a work-around.

Thanks.

Regards,
Christian

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


Re: Invalidate session

Posted by Bryan Lewis <br...@maine.rr.com>.
This has been discussed a few times before.  For example,
http://article.gmane.org/gmane.comp.java.tapestry.user/31641/match=illegalstateexception

As you say, Tapestry doesn't allow the exception to bubble up to the
user, but it does put a worrisome stack trace in the log.  The Tapestry
developers weren't highly motivated to fix this minor annoyance :-)  so
I just ignored it for a while, and then worked around it in my custom
Engine. It's not pretty but hey, it's a work-around.


    private static final String CLIENT_ABORT_EXCEPTION_NAME =
            "org.apache.catalina.connector.ClientAbortException";
    private static final String ILLEGAL_STATE_EXCEPTION_NAME =
            "java.lang.IllegalStateException";
    private static final String SESSION_INVALIDATED =
            "Session already invalidated";
    private static final String UNABLE_TO_RESET =
            "Unable to reset response buffer";

    public void reportException(String reportTitle, Throwable cause)
    {
        ExceptionDescription ed = null;

        // Don't log ClientAbortExceptions at all.
        ExceptionDescription[] edArray = new
ExceptionAnalyzer().analyze(cause);
        assert edArray != null;
        if (edArray.length > 0) {
            ed = edArray[0];
        }

        if
(ed.getExceptionClassName().equals(CLIENT_ABORT_EXCEPTION_NAME)) {
            log.debug("Not logging ClientAbort exc'n");
            return;
        }

        // Avoid the ugly stack trace that Tapestry puts in the log for the
        // IllegalStateException when a user logs out.
        if (ed.getExceptionClassName().equals(ILLEGAL_STATE_EXCEPTION_NAME)
            && (ed.getMessage().indexOf(SESSION_INVALIDATED) != -1
                || ed.getMessage().indexOf(UNABLE_TO_RESET) != -1))
        {
            // This debug message doesn't show up for some reason.
            log.debug("Not logging session-already-invalidated exc'n");
            return;
        }

        log.error(reportTitle);
        //.... the rest mimics what Tapestry's reportException() does.




Christian Haselbach wrote:

>Hello,
>
>how can a session be invalidadted gracefully? Simply calling
>session.invalidate() (where session for example was retrieved using
>WebRequest.getSession()) does invalidate exception, but will result
>in an exception later on in AbstractEngine. Here, the state manager
>is flushed which will complain about the missing session.
>
>The exception is catched by AbstractEngine. But an error is logged.
>
>Any ideas? Thanks.
>
>Regards,
>Christian
>
>---------------------------------------------------------------------
>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: Invalidate session

Posted by Konstantin Ignatyev <kg...@yahoo.com>.
I do it in the invalidate.jsp and then send redirect to the client to a desired page.


Christian Haselbach <ch...@tngtech.com> wrote: Hello,

how can a session be invalidadted gracefully? Simply calling
session.invalidate() (where session for example was retrieved using
WebRequest.getSession()) does invalidate exception, but will result
in an exception later on in AbstractEngine. Here, the state manager
is flushed which will complain about the missing session.

The exception is catched by AbstractEngine. But an error is logged.

Any ideas? Thanks.

Regards,
Christian

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




Konstantin Ignatyev




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)