It's not a secret anymore!
The moose likes Struts and the fly likes struts 1.2 action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 1.2 action class" Watch "struts 1.2 action class" New topic

struts 1.2 action class

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 580
In struts 1.2 action classes are singleton ,so each action class is multi threaded for serving many request.So I have to declare declare all parameter inside of execute method or can I declare outside of execute method.If it is declared outside ,when multi threaded it does not make any problem?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Struts 1 action classes are multithreaded, which means you must code them as thread-safe. In a thread-safe object, the only instance variables are those that do not change from one user to the next. All other variables should be local variables within methods.

For example, if you have a Logger class that writes to a log, it would be fine to make this an instance variable since the same instance of this class could safely be used by multiple users. However, if you have a variable called balance representing an individual user's account balance, it would be disastrous to make this an instance variable because one user could place a value in the variable and in the next thread another user could pick up the same value.

Consultant, Sima Solutions
I agree. Here's the link:
subject: struts 1.2 action class
It's not a secret anymore!