Issue
I was literally confused what happens when a container calls a servlet.
Can someone help me with how the instantiating and initializing works in servlets when a container calls it?
Solution
In order to load servlet container need to first instantiate servlet class and then before using it, servlet need to be initialize properly
After the servlet object is instantiated, the container must initialize the servlet before it can handle requests from clients. Initialization is provided so that a servlet can read persistent configuration data, initialize costly resources (such as JDBC connections), and perform other one-time activities.
In general Java class need to be loaded into class loader and then sometimes class can also have initialization code to be executed before it's used.
Answered By - user7294900
Answer Checked By - Katrina (JavaFixing Volunteer)