?– Web server.
In Java servlets, the init()
method is automatically called by the servlet container (e.g., Tomcat, Jetty) when the servlet is first loaded into memory. It is part of the servlet lifecycle and is invoked only once during the servlet’s initialization.
So, the correct answer to the question “Who is loading the init() method of servlet?” would be: The servlet container (or servlet engine) is responsible for loading and invoking the init()
method of a servlet.