When a jsp is accessed for the first time, the server is
slower in responding. This is because, every jsp page must be converted into an
instance of a servlet class before it can be used to service client requests.
For each request, the JSP engine checks the time stamps of the source JSP page
and the corresponding Servlet class file to determine if the jsp page and the
corresponding servlet class file to determine if the jsp page is new or if it
has already been converted into class file. Therefore, if we modify a JSP page,
the whole process of converting the JSP page into servlet is performed again.
The process consists of the following phases known as life cycle phases.
o
Page Translation
o
Page Compilation
o
Generated Servlet class loading
o
Servlet instantiation phase
o
Calling jspInit() known as initialization phase
o
Calling _jspService() known as servicing phase
o
Calling jspDestroy() known as destruction phase
Translation phase: During this phase , the jsp engine reads
the hsp page, parses it and validates the syntax of the tags, once the
validations are completed, the engine creates the java source code that
contains public servlet class.
Compilation phase: In this phase, the java compilation unit
generated in the previous phases is compiled. The result of this compilation is
the class file of the container generated servlet.
Instantiation phase:- The serlvet class is loaded
dynamically and the servlet engine creates the servlet instance.
Life cycle methods of ajsp: container generated servlet implements
javax.servlet.Servlet interface. jspPage
interface declares 2 methods.
JspInit()
JspDestroy()
HttpJspPage interface declares one method that serves the
Http Client requests.
jspServlice()
These methods are known as life cycle methods of a Jsp.
Initialization Phase: The container calls this method to initialize
the servlet instance.
Servicing Phase:- In this phase _jspService() method is
called by the container every time request
comes to the jsp.
Destruction Phase:- Whe the container is instructed to take
the servlet instance out of service, before the instance is sent for garbase
collection, container calls the life cycle method jspDestroy().
please see for better understanding some people may read or some people may see better understanding that's the reason i am giving every post one video. at least you can see the following video you can understand better way of this post.
Please click this link Life Cycle of JSP page
Post a Comment
In the JSP lifecycle, the destroy method is also invoked when the server shuts down
Post a Comment