• 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 Action Servlet

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does ActionServlet class in struts single threaded or multithreaded?.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is multithreaded, which means it must be coded as thread-safe. This means don't use instance variables unless you intend for them to be shared by all users of the application.
 
Rohit Dhodapkar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all thanks for the reply ..So does that mean than any instance variable in the action class is shared my multiple user .
If yes how can I avoid this situation .. My code has a requirement to keep instance varialbe which should be specific to a user ..How should I deal with itt..
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the instance variable is local to the action form, you may store it as a property in the actionForm bean. when the action form is mapped as session scope (default), it is stored as a session attribute and implicity loaded by struts when the action is used. Note that while the action handler needs to be thread safe, the actionForm bean is a bean.

another alternative if the data you want to store for a user is not specific to a screen or an action, you can store it into a normal session attribute.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone who is making instance variables in Action classes a "requirement" is asking for an application that doesn't work -- or even worse -- sometimes works and sometimes doesn't. If you need data for a single user to psersist between requests, put that data in the user's HTTPSession. For example:

String myData = "hello world";
request.getSession.setAttribute("myData", myData);

Then, in the next request, you can retrieve it with:

String myData = (String) request.getSession().getAttribute("myData");
 
Rohit Dhodapkar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for the reply
 
reply
    Bookmark Topic Watch Topic
  • New Topic