Two Laptop Bag
The moose likes Struts and the fly likes Thread Safe - Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Thread Safe - Struts" Watch "Thread Safe - Struts" New topic

Thread Safe - Struts

Akhil Chauhan

Joined: Jan 06, 2009
Posts: 2
Hi All,

Struts1 Action classes are not thread safe & instantiated only once.
So each request will access the same object.

Small Doubt -
If every request acess the same object.
What about the object inside the action classs, they will b instantiated per request or even they will behave same as Action class.
Ex -
List lst = new ArrayList();

Here -
ArrayList object wil be instantiated per request ?

Joe Ess

Joined: Oct 29, 2001
Posts: 9189

The code you have above has a variable in instance scope. There is one instance of that variable created for each instance of ActionClass, not for each request.
Have a look at the Action Class Design Guidelines

[How To Ask Questions On JavaRanch]
Akhil Chauhan

Joined: Jan 06, 2009
Posts: 2
thanks Joe
I agree. Here's the link:
subject: Thread Safe - Struts
It's not a secret anymore!