Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain JSP life cycle

Answer Posted / chantiraji

A JSP life cycle can be defined as the entire process from its creation till the destruction which is similar
to a servlet life cycle with an additional step which is required to compile a JSP into servlet.

The following are the paths followed by a JSP

1.Compilation

2.Initialization

3.Execution

4. Cleanup

The four major phases of JSP life cycle are very similar to Servlet Life Cycle

1. JSP Compilation:
-------------------
When a browser asks for a JSP, the JSP engine first checks to see 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.

The compilation process involves three steps:

1.Parsing the JSP.

2.Turning the JSP into a servlet.

3. Compiling the servlet.

2. JSP Initialization:
----------------------
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.

3.JSP Execution:
----------------
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...
}

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: The _jspService() method of a JSP is invoked once per a request and is responsible for generating the
response for that request and this method is also responsible for generating responses to all seven of the HTTP methods ie. GET, POST, DELETE etc.

4.JSP Cleanup:
--------------

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.

The jspDestroy() method has the following form:

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

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are methods?

964


What is a for loop in java?

991


What is Java Reflection API? Why it’s so important to have?

1076


What is stored procedure. How do you create stored procedure ?

1890


What is the generic class?

904


Write a program to show whether a graph is a tree or not using adjacency matrix.

1034


Explain an intermediate language?

894


What do you understand by the term string pool?

957


What are peerless components?

1029


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

931


What is indexof?

914


What are keywords and reserved words in java?

1002


Can an anonymous class be declared as implementing an interface and extending a class in java programming?

1164


Which container method is used to cause a container to be laid out and redisplayed in java programming?

1050


What is the order of arraylist in java?

1060