Two Laptop Bag*
The moose likes Struts and the fly likes Regarding ActionContext's ContextMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Regarding ActionContext Watch "Regarding ActionContext New topic
Author

Regarding ActionContext's ContextMap

Gaurav Kushwaha
Greenhorn

Joined: May 20, 2009
Posts: 19
Hi,

I have an application which will be used by multiple users. Currently, I am storing a object in session that will be used by multiple Actions Classes.
I want to avoid using session.
I tried using the ActionContext's getContextMap/parameters but it didn't help as I guess its clearing with every new request.

Please help !!
Samson Mlati
Ranch Hand

Joined: Feb 23, 2009
Posts: 41

Gaurav Kushwaha wrote:Hi,

I have an application which will be used by multiple users. Currently, I am storing a object in session that will be used by multiple Actions Classes.
I want to avoid using session.
I tried using the ActionContext's getContextMap/parameters but it didn't help as I guess its clearing with every new request.

Please help !!


Why don't you load it in a servlet?
Gaurav Kushwaha
Greenhorn

Joined: May 20, 2009
Posts: 19
Thanks for the reply.
The field that I am setting in session is not available beforehand, it gets filled up by an intermediary action class.
So I can't have that in the servlet.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
You could put the value into a hidden field in the html you send to the user. Then retrieve it from the request the user submits to the subsequent actions.
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

See in a basic servlet api there are 3 main scopes, request, session and application (ServletContext).
Struts "ActionContext" getContextMap/parameter gives a copy of context-params specified in web.xml.
These values are ment to be readonly once application is deployed, as per servlet api.

Hence, it did not worked out. And yes its a bug in Struts that ActionContext.getContextMap gives you a Map instance which is modifiable.


SCJP 91%, SCWCD 97%
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

Hence, They way it can be done is via session. But otherways like threadlocale could be thought of based onwhat requirement you have.
However, threadlocale solution will still be depedent upon some session value only.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding ActionContext's ContextMap
 
Similar Threads
action method not invoked
Keeping track of session id
Question on HttpSession
Session Variable
reusing sessions across multiple method calls