You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Bob Lee <cr...@crazybob.org> on 2002/04/02 18:24:50 UTC

Session Scope Question

The user guide says that if you use "session" scope, Struts will use the
"name" attribute from the "form-bean" element to key the instance. Does
Struts add something else to the key to prevent concurrent modification? For
example, if the user has two windows open and starts two different instances
of the same form, will the two instances modify the same ActionForm instance
in the session?

Thanks,
Bob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Session Scope Question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 2 Apr 2002, Bob Lee wrote:

> Date: Tue, 2 Apr 2002 11:18:42 -0600
> From: Bob Lee <cr...@crazybob.org>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: Re: Session Scope Question
>
> That's what I was afraid of. Is it possible to manually control which action
> form instance gets used? For example, rather than pass all of the data from
> page to page, pass an instance id that gets created when the user first
> enters the form.
>

There is no machinery to do this for session-based form beans, and it
would be very complex to implement (how do you tell each individual
request accessing the same session which id to use?).  That's why I
continue to encourage using request-based form beans instead, because each
request gets it's own instance -- the fact that the name is the same does
not matter.

> Thanks,
> Bob

Craig


>
> ----- Original Message -----
> From: "Craig R. McClanahan" <cr...@apache.org>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Tuesday, April 02, 2002 11:04 AM
> Subject: Re: Session Scope Question
>
>
> >
> >
> > On Tue, 2 Apr 2002, Bob Lee wrote:
> >
> > > Date: Tue, 2 Apr 2002 10:24:50 -0600
> > > From: Bob Lee <cr...@crazybob.org>
> > > Reply-To: Struts Developers List <st...@jakarta.apache.org>
> > > To: Struts Developers List <st...@jakarta.apache.org>
> > > Subject: Session Scope Question
> > >
> > > The user guide says that if you use "session" scope, Struts will use the
> > > "name" attribute from the "form-bean" element to key the instance. Does
> > > Struts add something else to the key to prevent concurrent modification?
> For
> > > example, if the user has two windows open and starts two different
> instances
> > > of the same form, will the two instances modify the same ActionForm
> instance
> > > in the session?
> > >
> >
> > No -- you've got the same multithread issues here that you do with
> > session-scoped attributes in general.  If your app is going to have cases
> > where the same form bean is used on more than one frame (or window) at the
> > same time, in the same session, I'd definitely architect things to use
> > request scope instead.
> >
> > > Thanks,
> > > Bob
> > >
> >
> > Craig
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Session Scope Question

Posted by Bob Lee <cr...@crazybob.org>.
That's what I was afraid of. Is it possible to manually control which action
form instance gets used? For example, rather than pass all of the data from
page to page, pass an instance id that gets created when the user first
enters the form.

Thanks,
Bob

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Tuesday, April 02, 2002 11:04 AM
Subject: Re: Session Scope Question


>
>
> On Tue, 2 Apr 2002, Bob Lee wrote:
>
> > Date: Tue, 2 Apr 2002 10:24:50 -0600
> > From: Bob Lee <cr...@crazybob.org>
> > Reply-To: Struts Developers List <st...@jakarta.apache.org>
> > To: Struts Developers List <st...@jakarta.apache.org>
> > Subject: Session Scope Question
> >
> > The user guide says that if you use "session" scope, Struts will use the
> > "name" attribute from the "form-bean" element to key the instance. Does
> > Struts add something else to the key to prevent concurrent modification?
For
> > example, if the user has two windows open and starts two different
instances
> > of the same form, will the two instances modify the same ActionForm
instance
> > in the session?
> >
>
> No -- you've got the same multithread issues here that you do with
> session-scoped attributes in general.  If your app is going to have cases
> where the same form bean is used on more than one frame (or window) at the
> same time, in the same session, I'd definitely architect things to use
> request scope instead.
>
> > Thanks,
> > Bob
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Session Scope Question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 2 Apr 2002, Bob Lee wrote:

> Date: Tue, 2 Apr 2002 10:24:50 -0600
> From: Bob Lee <cr...@crazybob.org>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: Session Scope Question
>
> The user guide says that if you use "session" scope, Struts will use the
> "name" attribute from the "form-bean" element to key the instance. Does
> Struts add something else to the key to prevent concurrent modification? For
> example, if the user has two windows open and starts two different instances
> of the same form, will the two instances modify the same ActionForm instance
> in the session?
>

No -- you've got the same multithread issues here that you do with
session-scoped attributes in general.  If your app is going to have cases
where the same form bean is used on more than one frame (or window) at the
same time, in the same session, I'd definitely architect things to use
request scope instead.

> Thanks,
> Bob
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>