You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jesse Vitrone <je...@agentscape.com> on 2005/04/09 16:36:16 UTC

session problems

I'm having some problems with my login page.  When a user tries to log 
in, I try to grab the session and use it for some stuff like this:

            FacesContext fc = FacesContext.getCurrentInstance();
            ExternalContext ec = fc.getExternalContext();
            HttpSession httpSession = (HttpSession) ec.getSession(true);
            httpSessionId = httpSession.getId();

And in my logout.jsp, I simple kill the users session with:

          session.invalidate();

This seems to work fine, but if I go to log back in quickly, the 
ec.getSession(true) call returns null.  I can try a few times, and I 
keep getting back null.  If I wait for a little while, then try again, I 
get back the session as I expect.  Any idea what's going on, and why I 
get back null for a little while?

I tried printing out the session id on my login jsp, just to make sure 
that Tomcat was actually giving me a new session directly after logout, 
and it is.  So after logout, I'm printing out a session id, and it's 
different that the first one from when I logged in the first time, but 
then I submit my form, and the ExternalContext is returning me null. 

Any ideas?

Thanks,
    Jesse

           



Re: session problems

Posted by Jesse Vitrone <je...@agentscape.com>.
I did a little more debugging, but didn't have any luck figuring out 
what's going on.  The only other interesting information that I was able 
to find was this:  when the login page shows me the session id, and the 
ExternalContext returns me null, and I wait for a while, then eventually 
get a session from the EC, it's giving me the same session that Tomcat 
created and I printed out on the login page.  So this session was 
created and I was able to display the session, but the EC didn't seem to 
get it for a little while.  Any idea why there is a delay like this 
after I do a session.invalidate?

Thanks,
    Jesse


Jesse Vitrone wrote:

> I'm having some problems with my login page.  When a user tries to log 
> in, I try to grab the session and use it for some stuff like this:
>
>            FacesContext fc = FacesContext.getCurrentInstance();
>            ExternalContext ec = fc.getExternalContext();
>            HttpSession httpSession = (HttpSession) ec.getSession(true);
>            httpSessionId = httpSession.getId();
>
> And in my logout.jsp, I simple kill the users session with:
>
>          session.invalidate();
>
> This seems to work fine, but if I go to log back in quickly, the 
> ec.getSession(true) call returns null.  I can try a few times, and I 
> keep getting back null.  If I wait for a little while, then try again, 
> I get back the session as I expect.  Any idea what's going on, and why 
> I get back null for a little while?
>
> I tried printing out the session id on my login jsp, just to make sure 
> that Tomcat was actually giving me a new session directly after 
> logout, and it is.  So after logout, I'm printing out a session id, 
> and it's different that the first one from when I logged in the first 
> time, but then I submit my form, and the ExternalContext is returning 
> me null.
> Any ideas?
>
> Thanks,
>    Jesse
>
>          
>
>
>
> .
>