JSP Life Cycle
a.)InstantiationEvent(when container creates JES class object)
Life cycle methods
These life cycle methods will be called through servlet life cycle method(init(ServletConfig))
b.)Request Processing Event
1.)jspInit()->for programmers initailization logic
2.)_jspInit()->for container initialization logic
2.)_jspInit()->for container initialization logic
Life cycle methods
These method will be called through servlet life cycle method 1st service(req,res)
1.)_jspService(-,-)
c.)Destruction Event(When container is about to destroy JES class object)
These method will be called through servlet life cycle method 1st service(req,res)
1.)_jspService(-,-)
Life cycle methods
These methods will be called through destroy() life cycle method of servlet component
1.)jspDestroy()-->for programmer
2.)_jspDestroy()-->for container
JSP life cycle methods are called through servlet life cycle methods with support of JES class super class(HttpJspBase in tomcat server)
These methods will be called through destroy() life cycle method of servlet component
1.)jspDestroy()-->for programmer
2.)_jspDestroy()-->for container
JSP life cycle methods are called through servlet life cycle methods with support of JES class super class(HttpJspBase in tomcat server)
Two phases of JSP
a.)Phase-1(Translation Phase)Here jsp pages will be translated into an equivalent servlet class source
first.jsp--pageCompiler-->first_jsp(JES source code)
b.)Phase-2(Request Processing/Execution Phase)
1.)Here jes class will be compiled, jes class will be loaded, instantiated and initialized
2.)calls _jspService(-,-) to process the request and to generate the response
first_jsp.java---->first_jsp.class--->_jspService(-,-) and response goes to browser...
4.)If JES class source is deleted, then the request given to jsp doesn't participates in request translation phase
Note: The jsp container internally preserves the jsp source code for every request until next request comes to that jsp and compares both source code(current request & previous request) by using special tools like WDIFF, ARAXIS, WINMERGE and etc... to check whether modifications taken place or not
5.)When <load-on-startup> is enabled on jsp component the jsp container performs following operations either during server startup or during the deployment of web application so the first request given to jsp directly participates in request processing due to these we can minimize response time of first request and we can equalize with other than first request
6.)The operations are
Jsp loading-->jsp parsing-->jsp translation(page compilation)-->JES compilation-->JES class loading-->JES class instantiation-->JES class initialization
Example:
- <servlet>
- <servlet-name>one</servlet-name>
- <jsp-file>/WEB-INF/pages/first.jsp</jsp-file>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- .....
- </servlet-mapping>
Note: There is no needing of configuring generated JES class in web.xml, because that class is generated by jsp container itself. So there is no need of configuring that class
I just needed to record a speedy word to express profound gratitude to
ReplyDeleteyou for those magnificent tips and clues you are appearing on this
site. Java and J2EE Training in Chennai | Java and J2EE Training Institutes in Chennai