• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Server instance

 
Shuaib Gill
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I change my servlet so that when multiple requests are calling the servlet, more than one instance of the servlet is created by the server?
This way everytime a reqest is made, the server creates an instance of the servlet. How can I make this happen? Any code will be very helpful.
Thank you,
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as i know, you may not be able to do this. According to servlet specs, one instance of servlet is created and each thread is generated to handle different request. You can make sure only one thread is used but you cannot increase the number of servlet's instance. Hope i am right.
 
Shuaib Gill
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure about that or like 50/50? I need to know for sure.
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never read about multiple instances of servlet being created in the books or papers i had read so far. In addition, it is very inefficient if you want more instances to serve the requests. I am not totally commit to multiple instances cannot be created. If you implement SingleThreadModel in your servlet, you may get one instance per thread when the many request are made. If you need definite answer, please refer to Servlet specification from sun site. Sorry for not giving you a definite answer. The is the site of servlet 2.2 spec. http://java.sun.com/products/servlet/index.html
[This message has been edited by SoonAnn Lim (edited August 10, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic