O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required