• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusion regarding the number of instances for concurrent servlet accessibility

 
Ranch Hand
Posts: 77
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You for clearing my doubt Ulf.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic