If you are used to creating web applications using Java EE, you probably will have already realized: most of the time it is all about dealing with requests and responses and the most popular way to do it 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 been doing in your code.