You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yaragalla Muralidhar <ya...@gmail.com> on 2013/09/25 13:09:15 UTC

action class

will action class gets created for every new request even when new request
is also to the previous actionclass?

*Thanks and Regards,*
Muralidhar Yaragalla.
*
*

Re: action class

Posted by Umesh Awasthi <um...@gmail.com>.
Short answer is Yes, for every new request , a new instance will be created
reason for this is simple, your action classes also work as Model in MVC
and in order to take care of thread safety, its better to create a new
instance.



On Wed, Sep 25, 2013 at 4:39 PM, Yaragalla Muralidhar <
yaragallamurali@gmail.com> wrote:

> will action class gets created for every new request even when new request
> is also to the previous actionclass?
>
> *Thanks and Regards,*
> Muralidhar Yaragalla.
> *
> *
>



-- 
With Regards
Umesh Awasthi
http://www.travellingrants.com/

Re: action class

Posted by Dave Newton <da...@gmail.com>.
On Wed, Sep 25, 2013 at 7:29 AM, Muniasamy Kanthasamy wrote:

> CGI will do that. But Struts/servlet has designed to overcome that.
> It will create one service and serve for all requests
>

Servlets and Struts 1 actions are instantiated "once" (not strictly true,
but in general).

Struts 2 actions are instantiated per-request, unless you're using Spring
and configured them to be singleton (as opposed to, say, prototype) scope.

Simple object instantiation is generally phenomenally cheap across JVMs.
Care should still be taken to make sure only things that need to be
initialized are actually initialized, but action instantiation is pretty
quick, and it solves a variety of issues that singletons have.

Which is "best" is likely debatable, and I still go back-and-forth in my
head about it.

Dave

Re: action class

Posted by Muniasamy Kanthasamy <mu...@gmail.com>.
Here is my idea,

CGI will do that. But Struts/servlet has designed to overcome that.
It will create one service and serve for all requests


On Wed, Sep 25, 2013 at 7:09 AM, Yaragalla Muralidhar <
yaragallamurali@gmail.com> wrote:

> will action class gets created for every new request even when new request
> is also to the previous actionclass?
>
> *Thanks and Regards,*
> Muralidhar Yaragalla.
> *
> *
>



-- 
Rgds,
Muniasamy K
Mobile :248-238-5883
Michigan,USA

Re: action class

Posted by Yaragalla Muralidhar <ya...@gmail.com>.
I think Dave is right. in struts 1 action is a singleton but in 2 it gets
created per request. Anyway thank.

*Thanks and Regards,*
Muralidhar Yaragalla.
*
*


On Wed, Sep 25, 2013 at 4:58 PM, Dave Newton <da...@gmail.com> wrote:

> Yes. Actions are created per-request.
> On Sep 25, 2013 7:19 AM, "Yaragalla Muralidhar" <yaragallamurali@gmail.com
> >
> wrote:
>
> > will action class gets created for every new request even when new
> request
> > is also to the previous actionclass?
> >
> > *Thanks and Regards,*
> > Muralidhar Yaragalla.
> > *
> > *
> >
>

Re: action class

Posted by Dave Newton <da...@gmail.com>.
Yes. Actions are created per-request.
On Sep 25, 2013 7:19 AM, "Yaragalla Muralidhar" <ya...@gmail.com>
wrote:

> will action class gets created for every new request even when new request
> is also to the previous actionclass?
>
> *Thanks and Regards,*
> Muralidhar Yaragalla.
> *
> *
>