File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Thread Safe - Struts

Akhil Chauhan
Greenhorn

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 -
ActionClass
{
List lst = new ArrayList();
}

Here -
ArrayList object wil be instantiated per request ?


Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

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

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Akhil Chauhan
Greenhorn

Joined: Jan 06, 2009
Posts: 2
thanks Joe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Safe - Struts