Java Server pages (JSP) is a server side programming language helps to build dynamic web based applications.
HTML code that contains java and Servlet is known as servlet
JSP uses simplified scripting language for embedding java servlet into HTML
JSP compiles on server It will be too slow while loading it for first time
Debugging is difficult when compared with java.
|Servlet run faster than jsp||Jsp run slower because of their compilation model|
|Servlet act as Controller in MVC pattern||JSP act as a View in MVC pattern|
|It is preferable to write code to control view page and connects your logic||JSP is preferable to build a design page that contains java objects|
|Custom tags cannot be build in servlet||JSP supports custom tag|
|Precompiled html cannot be used||Precompiled html can be used via taglib|
All JSP files are compiled into servlet code(.java) file and javac complier will convert the .java file to .class file
Ex: index.jsp will convert into index.java and then to index.class finally the html output is generated from the class file.
Will initialize the jsp code
All your logic and request response are processed here.
Will used to clean up the objects used by the jsp