Difference between Servlet and JSP?

In servlet we have to write Servlet class explicitly by extending HttpServlet or Generic Servlet
Container generates the servlet class per give JSP(in tomcat container generated Servlet extends HttpJspBase)
We have to compile the Servlet class written by us and we should move the .class file to WEB-INF/class folder
Container is responsible for compiling the generated Servlet class
We must configure the servlet in web.xml
No configuration required in the web.xml
Servlet can be loaded and initialized either at container startup or at first request
JSP will be compiled translated loaded and initialized always at first request only
Servlet Life Cycle methods are
  • init()
  • service()
  • destroy()
JSP Life Cycle methods are
  • _jspInit()
  • _jspService()
  • _jspDestroy


Post a Comment