java 1 Answer(s) 6 years and 8 months ago
Posted in : JSP-Servlet
July 30, 2008 at 12:05 PM
Main difference between Jsp and Servlet
Jsp is better for view web pages, while servlet is good for request processing.
Jsp has also all implicit objects, No need to instantiate any which is easier.
Jsp error handelling is easy in jsp isErrorPage="true" errorPage="/page".
Servlet life cycle having following steps. Servlet object is created Servlet init() : the servlet is initialized it needs arguments Servlet Config's object Servlet service() : where all work is done then servlet destroy() : that's the end of servlet.
Jsp life cycle
First .jsp is converted to .class in that is servlet it follows same step as Servlet it means Jsp in translated to servlet
In Jsp not bother init(),service(),destroy(),doGet(),doPost().
In servlet for each time changing need for compile it.
Jsp automatically compiled by container and reload the page.