JSP stands for JAVA Server Pages. It is JAVA Code inside HTML. It is useful technology for presentation layer or View in Model-View-Controller architecture.
Using JSP, developer can generate dynamic content on web pages. Major advantage of using JSP is that it separates business logic from presentation. Business logic can be implemented in JAVA and dynamic content is sent to JSP to display it on browser.
Life Cycle of JSP:
JSP has three life cycle methods: jspInit(), _jspService() and jspDestroy(). You can override jspInit() and jspDestroy() but you can not override _jspService() method.
When a request is sent to Server first time and server identifies right resource(JSP) to handle a request, JSP is first translated to a Servlet.
After translating to a Servlet, it gets compiled and create class file of the servlet.
After successfully creation of complied class file, JSP engine will call jspInit() method to initialize class file.
After initialization, service method is called and it handles the request and create response to be delivered to browser.
Once the service is completed and response is sent back, jspDestroy() method is called and it will clean up the resources.