GeeCON Prague 2014*
The moose likes Struts and the fly likes Action class instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action class instance" Watch "Action class instance" New topic
Author

Action class instance

Supri dharshni
Greenhorn

Joined: Jul 14, 2009
Posts: 25
Hi,


In struts , actionservlet will have only one instance.But for action class how many instances will be created.If it is going to be only one instance then for 100 requests will the same instance be maintained?Please clarify.



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

In Struts 1 there is a single Action created for each mapping.
Supri dharshni
Greenhorn

Joined: Jul 14, 2009
Posts: 25
Hi ,

Could you explain me in detail .I am using struts 1.2. While 100 requests are hitting the same action class whether only one instance is created for all the requests or one instance for one request(100 instances).
If only one instance is the case then how the response is send back to the each requests.Do the second request has to wait until the first request is completed?Please reply.

Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi,

Only one instance of action class is created per application, as we know for each request container will create separate thread hence for 100 request 100 theads will be creates and that 100 request can handle concurrently...(which is executing execute() method of action class's single instance) i.e. you can say class variable of action class is not at all thead safe.

hope this help.

Thanks,
Shailesh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Supri hunter wrote:Do the second request has to wait until the first request is completed?

No.
Supri dharshni
Greenhorn

Joined: Jul 14, 2009
Posts: 25
Thanks a lot. I got it.
 
GeeCON Prague 2014
 
subject: Action class instance