1. When a web container receives a jsp request (may be first or subsequent), it checks for the jsp’s servlet instance.
2. If no servlet instance is available or if it is older than the jsp, then, the web container creates the servlet instance using following stages.
1. Translation phase :
§ The process of Translating JSP page into the corresponding servlet (.java file) is called Translation Phase. This can be done by the Web container.
§ In the translation phase, the container validates the syntactic correctness of the JSP pages and tag files.Usually jsp phase will participate in Translation phase in the following calls.
§ 1) At the time of first request.
§ 2)If the source code of jsp got modify when compared with earlier request.For this Jsp engine user ARAXIS tool to compare Time Stamps of .jsp and .class files
§ Note:-If any problem raise while translation or compilation we will get Http 500.
2. Compilation phase :
The generated java servlet file is compiled into a java servlet class file .
3. Loading class :
The java servlet class that was compiled from the JSP source is loaded into the container.
4. Instantiation :
In this step, instance of the servlet class is created so that it can serve the request.
In our jsp page contain only jspInit() and jspDestroy() methods only .we need not to write _jspService() method.
The JSP specification has provided a special interface HttpJspPage for JSP pages serving HTTP requests and this interface contains _jspService().
5. Initialization : jspInit()
· Initialization is done by calling the jspInit() method.
· This is one time activity at the start of the initialization process.
· Initialization will make the ServletContext and ServletConfig objects available.
· After initialization the servlet is ready to process requests.
6. Request Processing : _jspService()
· This method is called for every request of this JSP during its life cycle.
· Entire initialization process is done to make the servlet available in order to process the incoming request.
· jspService() is the method that actually processes the request.
· It prints the response in html (any other) format, using ‘out’ object.
7. Destruction: jspDestroy() :
· Destruction:jspDestroy(): Whenever the server is shutting down or when the server needs memory, the server removes the instance of the servlet.
· The destroy method jspDestroy() can be called by the server after initialization and before or after request processing.
· Once destroyed the jsp needs to be initialized again.
No comments:
Post a Comment