You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Slawek <ss...@o2.pl> on 2005/02/14 21:10:04 UTC

logout and clear session

hi

problem: user cliks on menu with action logout...
how to clear all memory associated with his session (for ex. large beans)?

i can get session in action method:

	FacesContext facesContext = FacesContext.getCurrentInstance();
	SessionMap session = 
(SessionMap)facesContext.getExternalContext().getSessionMap();
	//session=null; - that doesnt clear session:/

and what should i do to clear memory (set null references to tell garbage 
collector to whipe out objects without waiting when session expires)?

thanks for your time Men!

Slawek

Re: logout and clear session

Posted by Heath Borders <he...@gmail.com>.
You need to get the actual session object from the externalContext and
call invalidate.


On Mon, 14 Feb 2005 21:10:04 +0100, Slawek <ss...@o2.pl> wrote:
> hi
> 
> problem: user cliks on menu with action logout...
> how to clear all memory associated with his session (for ex. large beans)?
> 
> i can get session in action method:
> 
>        FacesContext facesContext = FacesContext.getCurrentInstance();
>        SessionMap session =
> (SessionMap)facesContext.getExternalContext().getSessionMap();
>        //session=null; - that doesnt clear session:/
> 
> and what should i do to clear memory (set null references to tell garbage
> collector to whipe out objects without waiting when session expires)?
> 
> thanks for your time Men!
> 
> Slawek
> 


-- 
-Heath Borders-Wing
hborders@mail.win.org

Re: logout and clear session

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hi Rico,

I saw this code sniplet in some other
cases, so I included it in my logout stuff.

Tomcat's Struts based admin app does do the same.

-Matthias

Rico Wiese wrote:
> hi matthias,
> 
> whats the reason for this line of code:
> "session = request.getSession(true);"
> after "session.invalidate();" ??
> 
> regards
> rico
> 
> Matthias Wessendorf <ma...@matthias-wessendorf.de> schrieb am 
> 15.02.2005 08:57:25:
> 
> 
>>I guess you'll need something like:
>>
>><snip>
>>javax.servlet.http.HttpServletRequest request = 
>>(javax.servlet.http.HttpServletRequest)FacesContext.
>>getCurrentInstance().getExternalContext().getRequest();
>>
>>javax.servlet.http.HttpSession session = request.getSession();
>>session.invalidate();
>>session = request.getSession(true);
>></snip>
>>
>>HTH,
>>Matthias
>>
>>
>>
>>Slawek wrote:
>>
>>>hi
>>>
>>>problem: user cliks on menu with action logout...
>>>how to clear all memory associated with his session (for ex. large 
> 
> beans)?
> 
>>>i can get session in action method:
>>>
>>>    FacesContext facesContext = FacesContext.getCurrentInstance();
>>>    SessionMap session = 
>>>(SessionMap)facesContext.getExternalContext().getSessionMap();
>>>    //session=null; - that doesnt clear session:/
>>>
>>>and what should i do to clear memory (set null references to tell 
>>>garbage collector to whipe out objects without waiting when session 
>>>expires)?
>>>
>>>thanks for your time Men!
>>>
>>>Slawek
>>>
>>
>>-- 
>>Matthias Weßendorf
>>Aechterhoek 18
>>DE-48282 Emsdetten
>>Germany
>>phone: +49-2572-9170275
>>cell phone: +49-179-1118979
>>email: matzew AT apache DOT org
>>url: http://www.wessendorf.net
>>callto://mwessendorf (Skype)
>>icq: 47016183
>>
> 
> 

-- 
Matthias Weßendorf
Aechterhoek 18
DE-48282 Emsdetten
Germany
phone: +49-2572-9170275
cell phone: +49-179-1118979
email: matzew AT apache DOT org
url: http://www.wessendorf.net
callto://mwessendorf (Skype)
icq: 47016183

Re: Re: logout and clear session

Posted by Rico Wiese <Ri...@data-experts.de>.
hi matthias,

whats the reason for this line of code:
"session = request.getSession(true);"
after "session.invalidate();" ??

regards
rico

Matthias Wessendorf <ma...@matthias-wessendorf.de> schrieb am 
15.02.2005 08:57:25:

> I guess you'll need something like:
> 
> <snip>
> javax.servlet.http.HttpServletRequest request = 
> (javax.servlet.http.HttpServletRequest)FacesContext.
> getCurrentInstance().getExternalContext().getRequest();
> 
> javax.servlet.http.HttpSession session = request.getSession();
> session.invalidate();
> session = request.getSession(true);
> </snip>
> 
> HTH,
> Matthias
> 
> 
> 
> Slawek wrote:
> > hi
> > 
> > problem: user cliks on menu with action logout...
> > how to clear all memory associated with his session (for ex. large 
beans)?
> > 
> > i can get session in action method:
> > 
> >     FacesContext facesContext = FacesContext.getCurrentInstance();
> >     SessionMap session = 
> > (SessionMap)facesContext.getExternalContext().getSessionMap();
> >     //session=null; - that doesnt clear session:/
> > 
> > and what should i do to clear memory (set null references to tell 
> > garbage collector to whipe out objects without waiting when session 
> > expires)?
> > 
> > thanks for your time Men!
> > 
> > Slawek
> > 
> 
> -- 
> Matthias Weßendorf
> Aechterhoek 18
> DE-48282 Emsdetten
> Germany
> phone: +49-2572-9170275
> cell phone: +49-179-1118979
> email: matzew AT apache DOT org
> url: http://www.wessendorf.net
> callto://mwessendorf (Skype)
> icq: 47016183
> 

Re: logout and clear session

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
I guess you'll need something like:

<snip>
javax.servlet.http.HttpServletRequest request = 
(javax.servlet.http.HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();

javax.servlet.http.HttpSession session = request.getSession();
session.invalidate();
session = request.getSession(true);
</snip>

HTH,
Matthias



Slawek wrote:
> hi
> 
> problem: user cliks on menu with action logout...
> how to clear all memory associated with his session (for ex. large beans)?
> 
> i can get session in action method:
> 
>     FacesContext facesContext = FacesContext.getCurrentInstance();
>     SessionMap session = 
> (SessionMap)facesContext.getExternalContext().getSessionMap();
>     //session=null; - that doesnt clear session:/
> 
> and what should i do to clear memory (set null references to tell 
> garbage collector to whipe out objects without waiting when session 
> expires)?
> 
> thanks for your time Men!
> 
> Slawek
> 

-- 
Matthias Weßendorf
Aechterhoek 18
DE-48282 Emsdetten
Germany
phone: +49-2572-9170275
cell phone: +49-179-1118979
email: matzew AT apache DOT org
url: http://www.wessendorf.net
callto://mwessendorf (Skype)
icq: 47016183