This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes servlet init() called more than once Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet init() called more than once" Watch "servlet init() called more than once" New topic
Author

servlet init() called more than once

ravisha andar
Ranch Hand

Joined: Feb 25, 2011
Posts: 55
Hi All,

As per my reading the servlets init() method is called only once.

Is there any scenario in which it is called more than once ?

What happens whe we implement the singlethread model?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63202
    
  69

No. Not for the same servlet instance.

You should never implement the single thread model.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ravisha andar
Ranch Hand

Joined: Feb 25, 2011
Posts: 55
Thanks.

i will not implement.

I was asking for my knowledge. Since if we imement single threadmodel we get a new instance for each request, will the init() and destroy be called for each instance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63202
    
  69

Yes.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: servlet init() called more than once
 
It's not a secret anymore!