I use the "SessionAware" interface to retrieve a Map of the session.  Then to
invalidate the Session, I do this:

                if (session instanceof 
org.apache.struts2.dispatcher.SessionMap) {
                        // it is possible that the session will have timed-out 
between the
                        // point at which it was acquired above and now.  
Attempting to
                        // invalidate an already invalid session will result in 
an
                        // exception being thrown.
                        try {
                                
((org.apache.struts2.dispatcher.SessionMap)session).invalidate();
                        } catch (IllegalStateException ise) {
                                String msg = "'LogoutAction.logout()' caught an 
"
                                        + "IllegalStateException, possibly 
because the session "
                                        + "has already been invalidated or 
timed out.";
                                logger.warn(msg,ise);
                        }

- Ray Clough



newton.dave wrote:
> 
> --- "Srinivas.N." <[EMAIL PROTECTED]> wrote:
>> How do I invalidate the session?
> 
> You'd probably need to implement ServletRequestAware
> [1] and get the session from the request.
> 
> and get the session from there.
> 
> You could use ServletActionContext [2] but that might
> have a negative impact on testability; I haven't
> really given that any thought. (Has anyone else? Now
> I'm kinda curious.)
> 
> d.
> 
> [1]
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/interceptor/ServletRequestAware.html
> [2]
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/ServletActionContext.html
> 
> 
> 
>  
> ____________________________________________________________________________________
> Now that's room service!  Choose from over 150,000 hotels
> in 45,000 destinations on Yahoo! Travel to find your fit.
> http://farechase.yahoo.com/promo-generic-14795097
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--Session-Invalidation-through-SessionAware-interface-tf4003103.html#a11383650
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to