You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Elam Daly <el...@gmail.com> on 2006/03/01 15:47:44 UTC

Re: Session Expiration Default Target?

Thanks for the help Mike.  Worked like a charm.

-Elam

On 2/28/06, Mike Kienenberger <mk...@gmail.com> wrote:
>
> > > On 2/27/06, Elam Daly <el...@gmail.com> wrote:
> > >>how do I determine if a session has expired?
>
> > Mike Kienenberger wrote:
> > > You have to do something like this:
> > >
> > >             boolean expired = false;
> > >             try
> > >             {
> > >                  session.getAttribute("anything"):
> > >                  expired = false;
> > >             }
> > >             catch (IllegalStateException e)
> > >             {
> > >                 expired = true;
> > >             }
>
> On 2/28/06, Jonathan Harley <jo...@parkplatz.net> wrote:
> > No, in a filter you can just call session.isNew()
>
> That would be incorrect, although you could possibly replace
> getAttribute() with isNew() in the code above.
>
>
> public abstract boolean isNew()
>
>     A session is considered to be "new" if it has been created by the
> server, but the client has not yet acknowledged joining the session.
> For example, if the server supported only cookie-based sessions and
> the client had completely disabled the use of cookies, then calls to
> HttpServletRequest.getSession() would always return "new" sessions.
>
>     Returns:
>         true if the session has been created by the server but the
> client has not yet acknowledged joining the session; false otherwise
>     Throws: IllegalStateException
>         if an attempt is made to access session data after the session
> has been invalidated
>