• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
  • Core Java
  • Design Patterns
  • JSP
  • Servlets
  • Building Tools
  • jQuery
  • Spring
  • Hibernate
  • Mongo DB
  • More
    • HTML
    • SCJP
    • AJAX
    • UML
    • Struts
    • J2EE
    • Testing
    • Angular JS

J2EE Reference

  • Home
  • About Us
    • Java Learning Centers
  • Contact Us

JSP Life Cycle

December 30, 2010 By j2eereference 1 Comment

JSP Compilation:

When a request comes for a JSP, the JSP engine first checks whether it needs to compile the page. If the page has never been compiled, or if the JSP has been modified since it was last compiled, the JSP engine compiles the page.

JSP compilation involves three steps:

1) Parsing the JSP.

2) Converting JSP to a servlet.

3) Compiling the servlet.

1)     Initialize –  jspInit()

After compiling and loading the JSP page  it invokes the jspInit() method before servicing any requests. You can override the jspInit() method if there is any specific need for initializing your JSP.

public void jspInit(){

// Your Initialization code here.

}

 2)    service – jspService()

This is the next step after initialization of JSP . The _jspService() method takes HttpServletRequest and HttpServletResponse as its parameters as follows:

void _jspService(HttpServletRequest request, HttpServletResponse response) {

// Your code for handling service

}

  3)   Complete – jspDestroy()

The jspDestroy() method is the JSP equivalent of the destroy method for servlets. You can Override jspDestroy if you need to perform any cleanup, such as releasing database connections.

public void jspDestroy(){

// Your cleanup code goes here.

} 

Filed Under: JSP

Reader Interactions

Comments

  1. Jenise Steininger says

    May 29, 2011 at 10:26 pm

    Wow this is a great resource.. I’m enjoying it.. good article

    Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

FOLLOW US ONLINE

  • View J2eereference-166104970118637’s profile on Facebook
  • View j2eereference’s profile on Twitter
  • View j2eereference’s profile on LinkedIn

Subscribe by email

Recent posts

  • Java Buzzwords
  • Anonymous Inner Class in Java
  • Network Programming – java.net Package
  • Java Regular Expressions
  • Method Local Inner Class in Java
  • URL Processing in Java
  • Iterator Design Pattern Implementation using Java
  • Strategy Design Pattern Implementation using Java
  • Decorator Design Pattern
  • Adapter Design Pattern Implementation using Java
  • JSF Composite Components
  • JSF UI Components
  • What is JavaServer Faces (JSF)?
  • GOF Design Patterns
  • History and Need for Design Patterns

Footer

Core Java
Design Patterns
JSP
Servlets
HTML
Building Tools
AJAX
SCJP
jQuery
Testing
Spring
UML
Struts
Java Centers
Java Training
Home
About Us
Contact Us
Copyright © j2eereference.com. All right reserved.