How many objects are created when same or different client send 100 requests to a servlet?

Questions by sadashivarao   answers by sadashivarao

Showing Answers 1 - 32 of 32 Answers

Kishor Raja Kumar

  • Sep 18th, 2006
 

   Hi all,

    In any case, for servlet only one instance will be created.

   If i am wrong plz let me know.

  Bye

Kishor

supriya

  • Sep 25th, 2006
 

i think that,container create 1 instance if servlet is not implemention SingleThreadModel interface for no of req. but if it implement this interface it may create more than one instance.

syed

  • Oct 3rd, 2006
 

hi 

for any number of requests only one instance of servlet will bew created as long as the web application is usiong the single thread  model   

thois model is ideal when when number of hits for a servlet will not be much   

else code needs be written for synchronizing 

bye

  Was this answer useful?  Yes

DB

  • Oct 10th, 2006
 

HI TO ALL

It can access only onces at a time

its using instance created by container

by

DB

  Was this answer useful?  Yes

praveen

  • Oct 26th, 2006
 

If  you are    implementing Single Thread Model, container maintains servlet  instance  pool, when ever a request  comes , it is handled by a servlet  instance. Which is  opposite to basic design  of servlets.

  Was this answer useful?  Yes

Praveen Kumar

  • Oct 26th, 2006
 

Hi Supriya,

    I think you don't know the actually inside what happend.  So thats why you give like that answer.  Any how if you want more details please send me the mail to praveen.gci@gmail.com

  Was this answer useful?  Yes

Ami

  • Oct 26th, 2006
 

Hi,

Implementing SingleThreadModel means only onw thread can access an object at a time.

Now there are two ways to do so.

1) Instance Pooling: container can maintain a pool of instances and handover new instance to each incoming request.

2)Request Serialization:Container can maintain a single instance and then serialises the requests. i.e. While an instance is already in use, if other erequest comes, it has to keep waiting until the first request finishes the processing.

Let me know if any other issue is there,

Regards,

Ami

  Was this answer useful?  Yes

Bhumika

  • Dec 4th, 2006
 

hi!

Servlets support multithreaded as well as single threaded model .

So incase of multithreaded model obviously  the Java servlet can potentially service concurrent user requests.

While in case of single threaded model Server creates multiple instances of the servlet for each new user request

Note:

WebLogic Server provides support for defining a pool of the instances for the servlet. This pool is initialized when the servlet is initialized for the first time by the server. If the pool size is less than the average number of concurrent requests received for the servlet, the WebLogic Server increases the pool count. This setting of the pool size can be done by setting the value for the SingleThreadedServletPoolSize parameter in the WebLogic Server using the server administration console.

  Was this answer useful?  Yes

suresh

  • Jan 2nd, 2007
 

If the servlet do not implement "SingleThreadModel", the container can create multiple threads for the servlet instance. If the servlet got more than one request WebServer / Container spans a separate thread of the servlet to serve the request.

  Was this answer useful?  Yes

nit_bit

  • Feb 8th, 2007
 

If the servlet implements SingleThreadModel interface then many instances of that servlet can be created by the Container otherwise,(i) If the web application is a distributed webapplication then each JVM will have only one servlet instance no matter how many requests are there. But in all you can say that you have 1 or more than 1 servlet instances (present on many JVM but one servlet instance per JVM).(ii) If the webapp is not a distributed one then only one servlet instance(object) would be there to service all the requests. For each request you'll have a separate thread accessing service() method.Hey reply if I am wrong at any point above.Cheers !!Nitin

  Was this answer useful?  Yes

Sarysarin

  • Aug 20th, 2010
 

Regardless of the number of request only one instance of Servlet will be created by the container per servlet per jvm. This is true in case servlet has not implemented SingleThreadModel Interface. In the latter case there may be two scenarios either a pool of Servlet instances are created or container queue all the request and forwards them to the single Servlet instance.

  Was this answer useful?  Yes

Initially Servlet creates only one object to handle the request. When 100 request comes from client Servlet will create 100 threads to handle the client request.

  Was this answer useful?  Yes

when the request comes from the same client/browser for the 100 times the existing Servlet Object is retrieved
i.e if at all the request comes from the same browser/client new Servlet Object is not created
Servlet Object creation is browser/client wise not request wise..!!!!!!

new Servlet object will be created only when the request comes from the different browser/client

  Was this answer useful?  Yes

Satendra Mishra

  • Jan 30th, 2012
 

Only one instance create remain are composite object

  Was this answer useful?  Yes

kesav chari

  • Jun 28th, 2013
 

Only one ServletObject is Created , even multiple clients sends the request to server . Because that servlet object is removed when the Project is undeployed from the server or when stop the server

  Was this answer useful?  Yes

neeraj srivastava

  • Jun 16th, 2016
 

Yes, Servlet creates only one instance either request is 100 or 200..

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions