JSP Life Cycle
Hi All we are going to see the JSP life cycle.It involves from birth to death of JSP.If we have studied the advance java concepts or you are going to start JSP is most important thing to be understood by every java developer.
So what about the life cycle of JSP.
Stages in JSP Life Cycle
- First when user enters the url of jsp the jsp engine
- JSP engine loads the specified JSP compiles the JSP page.
- After compilation of JSP page it is converted and made as a Servlet .
- This servlet will live in Container servlet container.Servlet container is responsible for maintaining the life cycle means survival of the objects.
- Container creates instance of the jsp’s servlet.
- Whatever we have defined in the <%!%> is the declaration tag so the declarations done in the jsp goes in the jsp_init() which means when the serlvlet initializes it will be loading all the declared variables.
- Also whatever defined inside the <%%> is shifted to the jsp_service() method of the compiled servlet.
- jsp_destroy() this is last phase of jsp where jsp unloads.Here the jsp variables and objects are cleaned up (garbage collection takes place as our jsp is no more required.)
In short when ever jsp is compiled it follows the life cycle of servlet afterwords.
To get more details i would love to recommend you book jsp in action to quickly learn jsp.