Lifecycle of a JSP

You write the .jsp file.

The Container writes the .java file for the servlet your JSP becomes.

  1. Kim writes a .jsp file, and deploys it as part of a web app.

    The Container “reads” the web.xml (DD) for this app, but doesn’t do anything else with the .jsp file (until the first time it’s requested).

    image with no caption
  2. The client hits a link that asks for the .jsp.

    The Container tries to TRANSLATE the .jsp into .java source code for a servlet class.

    Note

    JSP syntax errors are caught in this phase.

    image with no caption
  3. The Container tries to COMPILE the servlet .java source into a .class file.

    image with no caption
  4. The Container LOADS the newly-generated servlet class.

    image with no caption
  5. The Container instantiates the servlet and causes the servlet’s jspInit() method to run.

    The object is now a full-fledged servlet, ready to accept client requests.

    image with no caption
  6. The Container creates a new thread to handle this client’s request, and the servlet’s _jspService() method runs.

    image with no caption

    Everything ...

Get Head First Servlets and JSP, 2nd Edition 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.