JSP’s life cycle can be grouped into following phases.
1. JSP Page Translation:
A java servlet file is generated from the JSP source file. This is the first step in its tedious multiple phase life cycle. In the translation phase, the container validates the syntactic correctness of the JSP pages and tag files. The container interprets the standard directives and actions, and the custom actions referencing tag libraries used in the page.
2. JSP Page Compilation:
The generated java servlet file is compiled into a java servlet class.
Note: The translation of a JSP source page into its implementation class can happen at any time between initial deployment of the JSP page into the JSP container and the receipt and processing of a client request for the target JSP page.
3. Class Loading:
The java servlet class that was compiled from the JSP source is loaded into the container.
4. Execution phase:
In the execution phase the container manages one or more instances of this class in response to requests and other events.
The interface JspPage contains jspInit() and jspDestroy(). The JSP specification has provided a special interface HttpJspPage for JSP pages serving HTTP requests and this interface contains _jspService().
5. Initialization:
jspInit() method is called immediately after the instance was created. It is called only once during JSP life cycle.
6. _jspService() execution:
This method is called for every request of this JSP during its life cycle. This is where it serves the purpose of creation. Oops! it has to pass through all the above steps to reach this phase. It passes the request and the response objects. _jspService() cannot be overridden.
7. jspDestroy() execution:
This method is called when this JSP is destroyed. With this call the servlet serves its purpose and submits itself to heaven (garbage collection). This is the end of jsp life cycle.
jspInit(), _jspService() and jspDestroy() are called the life cycle methods of the JSP.














figure for jsp life cycle is not given here..
nirav jain on November 14th, 2009 5:08 pmExcellent man, you really helped me.
Raj on November 22nd, 2009 9:07 pmthank you.
Keep it UP.
one thing I would like to Suggest you,
that you can Show JSP life cycle Diagramatically.
its really nice ………
Julfiur Rahman on December 14th, 2009 11:53 amit s very useful for knowing abt jsp..
vidhya on December 14th, 2009 9:30 pmthank u
thanx
sonya on December 24th, 2009 5:57 amit really helped me a lot in understanding JSP and its life cycle. keep it up
Thanks for helping me..
Ammu on December 29th, 2009 9:06 amIts clearly undersandale for beginners…..
Thanks for helping me..
Ammu on December 29th, 2009 9:11 amIts clearly undersandable for beginners…..
thanks bro…..it’s really helpful
ayush on January 8th, 2010 12:18 pmGreat work
I understood the JSp lifecycle fully
Jinesh on January 21st, 2010 7:32 amGood
Anonymous on January 22nd, 2010 7:15 amvery very simple and nice site thanks admin
rohan on February 7th, 2010 2:00 amIts the best page i have ever visited about jsp life cycle.
hassan syed on February 16th, 2010 10:16 ambest explanation for jsp life cycle in any java blog i have seen…..
Anonymous on February 16th, 2010 2:02 pmthanks for the definition on jsp life cycle. it’very useful.
mohan on February 25th, 2010 9:06 amJsp Lifecycle with a neat sketch:
Anonymous on March 3rd, 2010 6:15 pmCheck out the other information for this topic in your book.
Lifecycle explaination is Excellent
Shilpa on March 23rd, 2010 10:42 pmsimple and understandable………! nice work.
Anonymous on March 31st, 2010 4:08 pmexcellent.
Nagaraj on April 1st, 2010 6:16 amthank you very much for definition – a neat sketch for jsp life cycle too is suggested.
guru on April 2nd, 2010 12:19 pmthe contents are clearly presented in this site.good work !
radha on April 9th, 2010 9:16 amGood one
Anonymous on April 13th, 2010 6:31 amgood example for the life cycle
Anonymous on April 15th, 2010 11:05 amvery easy and nice example
chetnath on April 18th, 2010 3:42 pmExcellent post on jsp life cycle ! thanks a lot!
Javahere.com on April 25th, 2010 9:34 amGood explanation.Figure needed to explain the jsp life cycle completely.
Madhuparna Mukherjee on April 27th, 2010 6:20 amvery good exellent explenetion
ashok chauhan on April 27th, 2010 6:47 amexellent explenetion
ashok chauhan on April 27th, 2010 6:48 amI have been consistently asked for a diagram to explain JSP life cycle. Quite soon I will update it. Thanks guys.
Joe on April 27th, 2010 7:29 pmexcellent
charu on May 3rd, 2010 3:14 amso brief but fair enough, thanx
anonymous on May 9th, 2010 2:33 pmThanx for t clarity on life cycle phases. It was good explanation.
Niranjan on May 14th, 2010 9:32 amthank u so much for explaiing the jsp lifecycle ya,,,,,,,,,,,,,,,,,,,,,,,,,,
dinesh mca on May 21st, 2010 9:05 amby
dinesh mca
ramanathapurm(district)
Perfect Job Thanks Man.
amit on May 24th, 2010 7:01 ameasy and compact to answer in interviews
gourav on May 24th, 2010 5:57 pmcan any body explain point no 7 above
7. jspDestroy() execution:
This method is called when this JSP is destroyed.
whaether this method is called to destroy jsp/when jsp is destroyed.
Mahammad Seeraz on May 28th, 2010 5:41 amthnx in advance
EXCELENT info on life cycle
ashok on June 4th, 2010 3:06 amfantastic!!!mind blowin!!!
yamini on June 7th, 2010 6:29 amThanks, t u r explanation about the jsp Life Cycle
k, i have one dought pls replay to my mail
my mail :- shashibushan2008@gmail.com
In the WebContainer calls init() and destroy() methods call only once and Service() method calls zero or more than no. of times in SERVLET life cycle.
like in this way
jspInit() and _jspDestroy() methods call once or more than once?
shashibushan on June 13th, 2010 5:20 pmjspService() method calls Zero or more than no. of time ?
that game was called paratrooper
Sp on June 16th, 2010 7:11 pmThanks Sp, I too figured it out lately.
Joe on June 17th, 2010 8:11 amthank….
though i did a project using jsp ,still ni d`t know this basic
yes it help me lot……..keep it up..
AJAY DALVI on June 22nd, 2010 11:32 amReally small but efficient material for jsp .
Aman on June 23rd, 2010 7:10 amThanks! It was helpful,.
santosh on July 1st, 2010 9:40 amlife cycle flow is marvelous..thanks v want more infor about jsp..if anybody knows plz send to my mail id…..
sathya on July 6th, 2010 4:13 amReally It’s very useful for me….I’m gng to do project in jsp so plzzz give more inf about jsp and help for my project…
waiting for answer……
Thamayanthi on July 6th, 2010 4:17 ammy mail:ramya.cool88@gmail.com
Thamayanthi on July 6th, 2010 4:18 amIt’s very fantastic ….thanks pa….I need brief about jsp..send to my mail quickly..
swathika on July 6th, 2010 4:44 amplease tell me
if jsp which was called first time has been destroyed by using jspdestoy()method.Suppose if the server gets same jsp request what would happen second time whether it needs to execute all the lifecycle methods or only jspService().if it execute jspService() how it will be available because jsp already destroyed .
Thanks in advance.
kiran on July 14th, 2010 6:09 amthank you very much.this one help more to me.but here not given the daigram.
kothagattu srinivas on July 28th, 2010 5:28 pmThanks t’s very fantastic
Sandeep on August 12th, 2010 12:28 pmGood one Jeo…Neatly explained
Srikanth S on August 19th, 2010 8:59 pmThe content is very useful, and clearly explained.
Raghuram
Raghuram on August 31st, 2010 9:19 amVery good explanation ::
sudhakar on September 1st, 2010 1:11 pmThanks buddy , hope it remains in my brain till interview :-)
narinder on September 1st, 2010 5:29 pmthank! u for the info.
Premsathish on September 7th, 2010 4:25 amGood!
Anonymous on September 22nd, 2010 5:46 amok excellent
Anonymous on September 27th, 2010 2:41 pmi am satisfied
rama Devi on September 27th, 2010 2:43 pmplease tell me
if jsp which was called first time has been destroyed by using jspdestoy()method.Suppose if the server gets same jsp request what would happen second time whether it needs to execute all the lifecycle methods or only jspService().if it execute jspService() how it will be available because jsp already destroyed .
Thanks in advance.
Raj yadav on September 28th, 2010 5:55 amThanks buddy , hope it remains in my brain till interview :-)& I Hope you got lot of info:about jsp search now ok best of luck…………………………
Raj yadav on September 28th, 2010 6:01 amRAJ YADAV
Really fine work but now I have switched to .Net
Atique on October 6th, 2010 8:59 amEvery jsp page make a related servlet and servlet gets executed
Atique on October 6th, 2010 9:01 amvery good.nice attempt:)
Praveen Kumar N on October 12th, 2010 4:14 amthankx bro.. you helped me to pass exam..
Nithin on October 20th, 2010 6:38 pmThanks and that was a gud one.
Apurv on November 12th, 2010 7:13 am