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 Doubt of init method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubt of init method" Watch "Doubt of init method" New topic
Author

Doubt of init method

Abhay Choubey
Ranch Hand

Joined: Jun 02, 2011
Posts: 34
Hi All,

when a init() method call when client send a request or as apache tomcat server will start.

Thanks in advance
Abhay
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

First, init method is a call back method of a server. so, you dont have control on it. but in most of the container, you can ask server to start init method by requesting a servlet or at the time of starting a web application using load-on-startup tag .
Abhay Choubey
Ranch Hand

Joined: Jun 02, 2011
Posts: 34
calling the init method depends on the server and its configuration. it can be when -
server start or server get the first request. It is right

thanks in advance
Abhay
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

right!
Abhay Choubey
Ranch Hand

Joined: Jun 02, 2011
Posts: 34
Thanks a lot
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Abhay Choubey wrote:Thanks a lot

You are welcome
Sergey Baranov
Greenhorn

Joined: Aug 27, 2005
Posts: 18

According to specification:

Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
The servlet container calls the init method exactly once after instantiating the servlet. The init method must complete successfully before the servlet can receive any requests.


Sergey Baranov
 
Don't get me started about those stupid light bulbs.
 
subject: Doubt of init method
 
Similar Threads
Mechanism of init method to initialize servlet
Why is init() needed?
How to find if the servlet is newly created or it was already existing
when the init() method will be callled
exception handling