
A servlet is a Java class that run at the server end, it is instantiated when needed and destroyed when not needed by the Servlet container. The init() and destroy() methods of Servlet interface will allow us to know when a Servlet has been initialized or destroyed by the Servlet container, but the are more methods to know about.
The Java Servlet written in this test will print out a message in the web server's log during the following events: the class loading, the instantiation, the initialization, the service and on the destroying. Thanks to this messages, and playing with the Servlet container while looking at the server's log, we will see when each life cycle event occurs. This way, we will verify when the Servlet is loaded, when is instantiated, how the service is called for every request we make, and how the instance of the Servlet is destroyed when we undeploy the application.


