What is the difference between jsp and servlet life cycles?Servlet's life cycle comprises of the following steps:
a. servlet object is created.
b. init() method initializes the servlet using Servlet Config object as its argument.
c. service() method accomplishes all the work.
d. destroy() method ends the life of servlet.
In JSP's life cycle, after a jsp is translated into a servlet, it behaves in the same way as a servlet.
Thus, at first a ‘.jsp’ is converted into a ‘.class’ i.e. a servlet and the Servlet Life Cycle Steps are followed.
What is the difference between JSP and Servlet life cycles?In servlet life cycle, the servlet object is created first. The init() method is invoked by the servlet container and the servlet is initialized by its arguments. Servlet’s service() method is invoked next. And at the end, the destroy() method is invoked.
In case of a Java Server Page life cycle, the .jsp is converted into .class file which is a servlet and then follow the process of the servlet. In orther words, the .jsp is translated into servlet and the functionality is same as that of the servlet.