What is the Lifecycle of JSP?

JSP has following lifecycle stages:

  • Compilation: When a request is made for a JSP, the corresponding JSP is converted into Servlet and compiled. If there is already a compiled form of JSP and there is not change in JSP page since last compilation, this stage does not do anything.
  • <li><strong>Initialization</strong>: In this stage, jspInit() method is called to initialize any data or code that will be later used multiple times in _jspService() method. </li>
    <li><strong>Service</strong>: In this stage, with each request to JSP, _jspService() method is called to service the request. This is the core logic of JSP that generates response for request.</li>
    <li><strong>Destroy</strong>: In this stage, JSP is removed from the container/server. Just before removal, this stage performs the cleanup of any resources held by JSP.</li>

    Leave a Reply

    Your email address will not be published. Required fields are marked *