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.
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.
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.
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.
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.
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.