> On Jan 18, 2008, at 1:17 PM, Chris Pratt wrote: > > >> On Jan 18, 2008, at 1:02 PM, Dave Newton wrote: > >>> --- Ted Slusser <[EMAIL PROTECTED]> wrote: > >>>> I have a struts2 action that is having some parameters set by the > >>>> parameter interceptor. If I go to a second browser / computer and > >>>> call the action I am seeing the same values on the Action that were > >>>> previously set. Is this the normal behavior? Is there a way to > >>>> turn > >>>> it off? Do I need to listen for some event at the end of the > >>>> action > >>>> lifecycle and clear my variables manually? > >>> > >>> Shouldn't need to. Are you defining your actions in a Spring config? > >>> > >>> d. > >>> > > On Jan 18, 2008 11:07 AM, Ted Slusser <[EMAIL PROTECTED]> > > wrote: > >> Yes. > >> > > > > Make sure you set scope="request" on your Spring action beans or it > > will create only one instance of the bean and reuse it forever. > > (*Chris*) > > > On Jan 18, 2008 11:36 AM, Ted Slusser <[EMAIL PROTECTED]> wrote: > Great. thanks. That worked once I added this to the web.xml > > <listener> > > <listener-class>org.springframework.web.context.request.RequestContextListener > </listener-class> > </listener> > > Does it 'throw away' objects per request? Is this a performance > concern? What about object pooling, etc. I suppose it's easier to > throw it away rather than try and reset the state somehow which could > lead to some pretty big problems. >
Basically Struts 2 always creates a new instance of the Action for each request. With all the confusion and threading problems that reusing Servlets caused, the Struts 2 developers decided it would be much safer to remove that part of the learning curve by using a new Action for each request. The overhead is minimal, but you have to be aware this is happening so that you don't put a bunch of initialization code in your actions. (*Chris*) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]