banner



How Many Objects Of A Servlet Will Be Created By App Server

  • Home
  • Interview Questions
  • J2EE
  • Servlets

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

Questions by sadashivarao   answers by sadashivarao

  • First
  • Prev
  • Next
  • Last

Showing Answers 1 - 16 of 16 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

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.

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

HI TO ALL

It can access only onces at a time

its using instance created by container

by

DB

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.

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

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

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.

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.

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

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.

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.

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

Satendra Mishra

  • Jan 30th, 2012

Only one instance create remain are composite object

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

neeraj srivastava

  • Jun 16th, 2016

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

Related Answered Questions

  •   Not able to store the data in my database
  •   Oracle forms tab detection
  •   Identify dml impacted objects
  •   .Rec file not created
  •   Test scenarios for view functinality
  •   Mobile testing interview questions
  •   To add the runtime property of an object into the excel sheet
  •   Jcl to send sms to mobile
  •   2 isp working in one network
  •   Leadership quality

Related Open Questions

  •   Responsibility of qa/test engineer when user finds a bug and how to handle the situation?
  •   Client / server application internal work
  •   How to differentiate GL, AP objects based on key terms - peoplesoft
  •   Srn scheduling
  •   Windows server 2008 r2 automatic freeze up problem
  •   Datacopy
  •   Test scenarios for 'create and send email' functionality
  •   Apply form handlers in existing Oracle forms
  •   Get requirement from client
  •   Computer network node packet transmission
  • Open Questions
  • Answered

How Many Objects Of A Servlet Will Be Created By App Server

Source: http://www.geekinterview.com/question_details/34528

Posted by: moorekrounist.blogspot.com

0 Response to "How Many Objects Of A Servlet Will Be Created By App Server"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel