You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Germuska <Jo...@Germuska.com> on 2006/01/18 17:09:45 UTC

Re: Action Framework: simultaneous requests on the same path, in the same session.

>but I wonder if that's a good idea.
>Am I missing something here? Is there a way to ensure that the 
>action is called each time with the set of parameters it was 
>supposed to receive?

If your forms are request scoped, there should be no problem; a new 
object would be created each time.

If you must use session scoped forms, it's not so easy, as the 
"token" mechanism for dealing with "double-posts" is not automatic; 
you must invoke it from your action, which means that the 
population/corruption may have already happened.

If you are actually using JavaScript to submit these forms, then I'd 
suggest adding some JavaScript which sets a "submitted" flag and 
tests it before actually causing a submit, setting it to true after 
it does submit.  I think that in a single page (not frame), things 
should be single-threaded so that this is relatively safe.

The other solution would be to extend the RequestProcessor to add a 
token validation step earlier than in the Action's execute() method. 
Actually, in Struts 1.3 this would be easier for all the reasons that 
Struts 1.3 makes changing the request processing path easier.  You 
could make a "validate token" command which would check the 
ActionMapping to see if it had been configured to "require valid 
token" (probably using Struts 1.3's "arbitrary config properties") 
and if that configuration had been set, you'd do the validation 
(which can be done using ActionContext), and if the validation 
failed, you'd probably fall back to using some other configuration 
property of the ActionMapping to determine the fallback action.

It actually seems like something which would be useful to add to the 
Struts 1.3 core, and perhaps even into the default chain. 
Unfortunately, I don't have time to code up something like that this 
month, but if you're interested, I can at least try to field basic 
questions here on the list (and hopefully so can others!)

The use of tokens in Struts 1.3 is probably something which could use 
a bit of a workout anyway; I can't remember why offhand, but I had 
some questions about how I adapted the processing model from Action 
to ActionContext and I haven't had an opportunity to really give that 
a workout myself.

Joe

-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com    

"You really can't burn anything out by trying something new, and
even if you can burn it out, it can be fixed.  Try something new."
	-- Robert Moog

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Action Framework: simultaneous requests on the same path, in the same session.

Posted by Michael Jouravlev <jm...@gmail.com>.
On 1/18/06, Joe Germuska <Jo...@germuska.com> wrote:
> >but I wonder if that's a good idea.
> >Am I missing something here? Is there a way to ensure that the
> >action is called each time with the set of parameters it was
> >supposed to receive?
>
> If your forms are request scoped, there should be no problem; a new
> object would be created each time.
>
> If you must use session scoped forms, it's not so easy, as the
> "token" mechanism for dealing with "double-posts" is not automatic;
> you must invoke it from your action, which means that the
> population/corruption may have already happened.

Token is unrelated to this problem. Token prevents double submit (on
server level). What he has is "populate, populate, execute, execute"
instead of "populate, execute, populate, execute".

The synchronization is definetely in order, but on a session, not on a
form, I guess.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org