Chapter 11. JSP and Servlet Lifecycles

In this chapter

Now that you understand the major features of JSP and servlets, it's time to drill down into some of the underlying structure. It is important to understand the JSP and servlet lifecycle: when and how servlets and JSPs are loaded, executed, and unloaded. Because Java Server Pages are also servlets, it makes sense to start with servlets.

Servlet Lifecycle

A servlet goes through four phases:

  • Loading

  • Initialization

  • Execution

  • Cleanup

Servlet Loading

A servlet can be loaded at three different times: when the server starts up, when the system administrator asks the server to load the servlet, or when a browser tries to access the servlet. ...

Get Special Edition Using Java™ Server Pages and Servlets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.