It's not a secret anymore!
The moose likes Servlets and the fly likes servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlets" Watch "servlets" New topic


jasvinder Pal singh

Joined: Oct 04, 2011
Posts: 6
in how many different ways a init() method can get executed.?
olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81

One way...

"Servlet init methods allows a servlet to perform one-time initialization prior to servicing requests."

"When a server loads a servlet, it runs the servlet's init method. Once."
Tim Moores

Joined: Sep 21, 2011
Posts: 2413
What prompted the question? It doesn't seem to make much sense.
jasvinder Pal singh

Joined: Oct 04, 2011
Posts: 6

what i meant is..
there are two ways
1) first when the servlet get deployed in a web server container for the first time
2) when the client call the first request.

i was wondering is there any 3 way of doing it.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Sorry, there is only one way - your 2 is the same as your 1. The container will call init after the servlet instance is created and before the first request is processed, no matter what sequence of events caused the creation.

I agree. Here's the link:
subject: servlets
It's not a secret anymore!