struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Newfield <>
Subject Re: Session object null
Date Tue, 18 May 2010 16:49:44 GMT
On 5/18/10 12:35 PM, Ken wrote:
> What I don't understand is I have an object who's constructor needs
> session data...
> So it calls:
> Map session = ActionContext.getContext().getSession();
> But session is always null...

Explains that this static method works by looking up the value in a 
ThreadLocal: "Returns the ActionContext specific to the current thread."

So if that constructor is happening within the same thread in which the 
request was originally being processed, and after xwork finishes setting 
up that context, it should work:

"The ActionContext is thread local which means that values stored in the 
ActionContext are unique per thread. See the ThreadLocal class for more 

But random code in a random thread occurring at a random time cannot 
rely on ActionContext.getContext().

I'd check out the *Aware interfaces if I were you.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message