This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion regarding the number of instances for concurrent servlet accessibility

 
Shivom Shukla
Ranch Hand
Posts: 77
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having this confusion, that if 5 clients (different web browsers or machines) are accessing one servlet at the same time, how many instances will be created of that servlet?
I know that servlet works on generating threads for processing the request from a particular web browser.

P.S. I know this is the incorrect forum to ask this but will this same thing happen in struts 2.0 action class in this same scenerio?

Thanks,
Shivom Shukla
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One instance of the class will be created, which will be used for all concurrent threads. That's why it is important to write servlets in a thread-safe manner.

Struts 2 action class objects are created for each request, so they need not be tread-safe. Note that this is different from Struts 1.
 
Shivom Shukla
Ranch Hand
Posts: 77
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

One instance is created if there are multiple requests from same client but,
will there be One instance created even if there are requests from different clients(web browsers) ?

So in struts 2.0, will there be different instances of the action class if more than one client try to access it?

Thanks,
Shivom
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has nothing to do with where the requests come from - there is no difference between requests coming from the same client, and requests coming from different clients, as far as the server is concerned.
 
Shivom Shukla
Ranch Hand
Posts: 77
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for clearing my doubt Ulf.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic