<snip>
If this is case then ActionForm are not thread-safe.  Because Two request
from different client can simultaneous come in and use the same ActionForm
instance?

I know this is not the case, but I cannot figure out how is it thread safe?
</snip>

Actually it is the case! - but only in certain cases when you have a session
scoped actionform.

Under these conditions it is possible for more than one thread to be playing
with that actionform at the same time. Where this could occur is when the
user has multiple windows open (or does a very rapid double submit) and
fires requests in both windows that map to the same action mapping.

You will note that it only affects that particular session. Other sessions
running at the same time will have their own actionforms of course, and
different actionmappings can use different attribute keys to store the form
under.

So you only have a problem where you need to support multiple windows/frames
(and thus potentially threads) for the same actionmapping for the same http
session and you use session scoped forms. (Ive been there. Its a pain)

We had a wee bit of a discussion about this last week in the context of
'workflow scopes':
http://marc.theaimsgroup.com/?l=struts-user&w=2&r=1&s=Request+against+Sessio
n&q=b

And the moral of the story?
Always keep your action forms REQUEST scoped if possible. (Sometimes it isnt
, but 95% of the time it IS possible with a bit of thought and extra effort)

(Request scoped forms only exist while a single thread is processing an
action so they are always thread safe)



-----Original Message-----
From: Amish Patel [mailto:[EMAIL PROTECTED]
Sent: Sunday, 22 February 2004 02:18
To: [EMAIL PROTECTED]
Subject: ActionForms Thread Safe


Hello All,

I am new to struts.  I have been reading about it and they way I understand
the framework instantiate ActionForm is as follows. ......

1) Check to see if an instance of the ActionForm already has been created.

2) If an ActionForm instance is present in the appropriate scope and it's
the same type as needed for the new request, reuse it.
Otherwise, create a new instance of the required ActionForm and store it in
the appropriate scope (set by the scope attribute for the action element).


If this is case then ActionForm are not thread-safe.  Because Two request
from different client can simultaneous come in and use the same ActionForm
instance?

I know this is not the case, but I cannot figure out how is it thread safe?

Please help!
Thanks
-Semplice

_________________________________________________________________
Get a FREE online computer virus scan from McAfee when you click here.
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to