GeekInterview.com
Series: Subject: Topic:
Question: 64 of 177

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

Asked by: sadashivarao | Member Since Mar-2006 | Asked on: Sep 13th, 2006

View all questions by sadashivarao   View all answers by sadashivarao

Showing Answers 1 - 14 of 14 Answers
Kishor Raja Kumar

Answered On : 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

Yes  1 User has rated as useful.
  
Login to rate this answer.
supriya

Answered On : 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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
syed

Answered On : 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

  
Login to rate this answer.
DB

Answered On : Oct 10th, 2006

HI TO ALL

It can access only onces at a time

its using instance created by container

by

DB

  
Login to rate this answer.
praveen

Answered On : 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.

  
Login to rate this answer.
Praveen Kumar

Answered On : 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

  
Login to rate this answer.
Ami

Answered On : 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

  
Login to rate this answer.
Bhumika

Answered On : 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.

  
Login to rate this answer.
suresh

Answered On : 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.

  
Login to rate this answer.
nit_bit

Answered On : Feb 8th, 2007

View all answers by nit_bit

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

  
Login to rate this answer.
Sarysarin

Answered On : Aug 20th, 2010

View all answers by Sarysarin

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.

  
Login to rate this answer.
subhash.sirsi

Answered On : Aug 20th, 2010

View all answers by subhash.sirsi

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.

  
Login to rate this answer.

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

  
Login to rate this answer.
Satendra Mishra

Answered On : Jan 30th, 2012

Only one instance create remain are composite object

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.