Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 61054
    
  66

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: 61054
    
  66

Yes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet init() called more than once