This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

statement about init() method  RSS feed

 
Iftikhar Arain
Ranch Hand
Posts: 95
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init() is called only once per instance. And it is called when the servlet container loads the servlet. In cases of high load, it may also instantiate multiple instances of a servlet. In this case, init() will be called on each of the instances.
I think according to the API if servlet does not implement SingleThreadModel then only one instance is created and mutiple threads share this instance.
 
Dominic Steng�rd
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The init(ServletConfig) method will only be called once. The only two exceptions are if you have declared that this class will implement the SingleThreadModel interface or if more than one <servlet> element is defined in the web.xml file having the same servlet class names.
Regards
[ October 19, 2002: Message edited by: Dominic Steng�rd ]
 
Iftikhar Arain
Ranch Hand
Posts: 95
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dominic .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!