struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: action class
Date Wed, 25 Sep 2013 12:45:59 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message