aspose file tools*
The moose likes Struts and the fly likes Action Class - Thread safe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action Class - Thread safe " Watch "Action Class - Thread safe " New topic
Author

Action Class - Thread safe

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi,

In our struts action class....we take the inputs from the formbean object and based on the values assign it to a object that represents all input params.

In formbean we have limited form fields but the object representing the input params has more values...

the scope of this object is...limited to the execute method

Request 1) ..some of the values in the object representing request will be populated

Request 2) ..Some value in the inputs is empty but the object representing request (not formbean) is still having the data from the earlier request

Struts version : 1.2 ...doesnt it spawn new threads and hence this object will be created

Regards








Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

In strtus1.2 action class is not thread safe we have to handle it because only one instance action class serve all the requests where it was modified in struts2. For each request new object will be created no need to bother about thread safe.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Yeah i agree with this...

For each request new object will be created no need to bother about thread safe....


but my query was...why do i still see old values for 2nd request.....

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action Class - Thread safe