Setup Menus in Admin Panel

2. Jsp life cycle

JSP life cycle is also managed by container. Usually every web container that contains servlet container also contains JSP container for managing JSP pages.

  • conversion
  • Compilation
  • Instantiation
  • Initialization
  • service
  • Finalization
  • Destruction

Conversion

The JSP converter/translator is a part of webserver that is responsible to translate the JSP page into servlet.

Compilation

If the translation is successful, then container compiles the generated servlet source file to generate class file.

Instantiation

In this phase, Servlet Container Instantiate the servlet class.When a container loads a JSP it invokes the jspInit() method before servicing any requests. If you need to perform JSP-specific initialization, override the jspInit() method:

public void jspInit()
{
// Initialization code...
}

Typically initialization is performed only once and as with the servlet init method, you generally initialize database connections, open files, and create lookup tables in the jspInit method.

Service

This phase of the JSP life cycle represents all interactions with requests until the JSP is destroyed.

Whenever a browser requests a JSP and the page has been loaded and initialized, the JSP engine invokes the _jspService() method in the JSP.

The _jspService() method takes an HttpServletRequest and an HttpServletResponse as its parameters as follows:

void _jspService(HttpServletRequest request,
HttpServletResponse response)
 {
    // Service handling code...
 }

Finalization

The destruction phase of the JSP life cycle represents when a JSP is being removed from use by a container.

The jspDestroy() method is the JSP equivalent of the destroy method for servlets. Override jspDestroy when you need to perform any cleanup, such as releasing database connections or closing open files.

public void jspDestroy()
{
  // Your cleanup code goes here.
}

Destruction

Destroy the servlet instance.

Download the code

January 16, 2016

0 responses on "2. Jsp life cycle"

Leave a Message

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

About Us

Pradeep Academy is an online & Training institute To make learning easy, interesting, affordable and accessible to millions of learners across the Globe. To create an alternative learning platform, using a unique learning methodology of live online interactive courses along with 24x7 support. We aim to empower our customers with skills which will help them get an edge in their careers and improve their lives.

Contact Us

Address :

PradeepIT Consulting Services Pvt Ltd

205,Brigade gardens, No.19 Church Street , Bangalore – 560001, Karnataka, India

Email : [email protected]
Ph No: 08047363377
Web: https://academy.pradeepit.com
top
© Pradeep Academy.  Design & Developed by