• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding ActionContext's ContextMap

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !!
 
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 88
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Shashank Ag
Ranch Hand
Posts: 88
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic