JSP lifecycle phases

A JSP page is converted into servlet before service requests. JSP Lifecycle consists of following phases:

JSP Page Translation:

The container validates the JSP page and parse it to generate the servlet file.

JSP Page Compilation:

The generated servlet file is compiled into a servlet class.

Class Loading:

Container loads the generated servlet class into memory.

Instantiation:

Container invokes the no argument constructor of generated servlet class to load it into memory and instantiate it.

Initialization:

After creating the instance, jspInit() method is called to initialize it.

Request Processing:

The _jspService() is called by web container every time when a request is come for the jsp. Syntax:

public void _jspService() throws ServletException,IOException

Note: In this method underscore (_) represents that implementation of this method is provided by auto generated servlet and it can’t be overridden by developer.

Destroy:

The jspDestroy() method is called by web container to unload JSP from memory.

Please follow and like us:
Content Protection by DMCA.com