Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action class instance

 
Supri dharshni
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Struts 1 there is a single Action created for each mapping.
 
Supri dharshni
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Supri hunter wrote:Do the second request has to wait until the first request is completed?

No.
 
Supri dharshni
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. I got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic