If you are used to creating web applications using Java EE, you probably will have already realized that most of the time, it is all about dealing with requests and responses, and the most popular way to do that is by using the Servlet API.
This recipe will show you how the server deals with its life cycles and what you should and should not be doing in your code.