Results 1 to 3 of 3

Thread: Instances of servlet

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Answers
    3

    Instances of servlet

    When multiple requests are sent by multiple clients at the same time, how many servlet instances are created

    Can we create multiple instances of the same servlet without implementing SingleThreadModel interface

    can anyone help me on this issue


  2. #2
    Banned
    Join Date
    Jan 2008
    Answers
    25

    Re: Instances of servlet

    Hi,
    only one servlet instace is created by servlet container.We cannot create a servlet instance explicitly. And for single instance multiple threads are created. If you implement SingleThreadModel interface only one thread will access the servlet instance otherwise multiple threads will access it simulaneously.
    Still if you have any issues please let me know.

    Thanks
    --suresh--


  3. #3
    Junior Member
    Join Date
    Apr 2011
    Answers
    1

    Smile Re: Instances of servlet

    Quote Originally Posted by srikanthm2 View Post
    When multiple requests are sent by multiple clients at the same time, how many servlet instances are created

    Can we create multiple instances of the same servlet without implementing SingleThreadModel interface

    can anyone help me on this issue
    As far as number of instances of servlet is concerned it depends on the servlet container implementation i.e container vendors how they implement the servlet specification.
    They may create multiple instances and use servlet pooling.

    If the servlet container is made to create only one servlet instance by default then also you can create more than one. In the web.xml file declare the servlet taggings multiple times but the name should be different or it will give DTD error. to check this write a default constructor in the class make load on startup tag +ve and start tomcat6 u will c the constructor is called twice. Thus we an have as many servlets as we want.
    The instances are called using the servlet name's value. In this case also only the first declaration will be used and its initial configs to serve the requests. Not he second one. only thing is that we can get multiple instances explicitly but will be useless as the call to the instance is done implicitly by container and it will use the one name value only. To support this we can say that for the same servlet we can have two contradictory configuartions so thats worthless.

    Hope it helps


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact