Like any object in
Java, Servlet is also an object.
Before init () method, the no-argument constructor of the Servlet class is called by the container but that only helps creating an object.
Servletness is granted to that object by Container by giving it ServletConfig object when its init(ServletConfig sg) method is called & always happens before the servlet can service any client requests.
init(ServletConfig sg) method helps give deployment information (like references to other sources in the Web App and database connections) which cannot be hard-coded in the Servlet (viz. Servlet initParameters).
ServletConfig object gives it servlet initParameters and also gives ServletContext object which helps it to communicate (secret-handshake between the Servlet and Web Container) throughout the Web App with the help of attributes.
Note:
The Container reads the Context initParameters from the Deployment Descriptor before Servlet initParameters and passes them to ServletContext object.
Then, servlet initParameters are read and given to the ServletConfig object which is then passed to the servlet’s init(ServletConfig sg) method and it is through ServletConfig object that we get ServletContext object.
The no-argument init ( ) method can be overridden in our Servlet if we have initialization code like getting database connection or registering ourselves with other objects. This no-argument init () method otherwise is called from the init (ServletConfig sg) method.
I guess that resolves your query...