• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Instances of a Servlet

 
Abhinay Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Is there any way to have multiple instances of a servlet even if we are not implementing SingleThreadModel ?

Please let me know if there is a way.

Thanks in advance,
Abhi
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want multiple instances of a servlet?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is yes, you can. Ben's question is more interesting though
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have a separate instance of a servlet for each distinct entry in a web.xml deployment descriptor. I suppose you could have the same servlet code playing dozens of different roles in the same or different "web applications".
Sometimes people do this by accident and we get the "why do I see two init() messages from my servlet" question.
Bill
 
Abhinay Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you all for the quick help.

Thanks a lot, William
Your post has answered all my queries about this issue.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhinay,

You never told us why.
 
Abhinay Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
I was discussing some concepts with my friends who are planning for SCWCD certification and this was one of the doubts. This was the only reason I asked this question
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Raja gopal Y
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Easiest way is to use the

<load-on-startup>

tag of web.xml

Any comments !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic