What is difference between JSP and Servlet?


It stands for Jakarta Server Pages or Java Server Pages. JSP is a server-side technology that is used for creating web applications. JSP pages are executed on a web server, and the resulting output is sent to the client’s web browser. It provides a way to easily access Java code and objects from within a web page, simplifying the creation of dynamic web pages.


Servlet is a small program that executes on the server side of the web application. Like Applet dynamically extends the functionality of a web server. Servlet Life Cycle can be defined as a series of steps through which a servlet goes during its life span.

1. JSP is a HTML-based code1. Servlet is a java code
2. It is easier to code in JSP2. It is hard to write code in servlet
3. It runs slower than servlet3. It runs faster than JSP
4. In MVC architecture, JSP works as a view.4. In MVC architecture, Servlet works as a controller.
5. It can accept all protocol requests, including HTTP5. It can only accept HTTP request
6. In JSP, you can't override the service() method6. In Servlet, You can override the service() method
7. In JSP, session management is enabled7. In Servlet, session management is not enabled
8. In JSP, Java code is written inside the HTML code.8. In Servlet, HTML code is written inside the Java code.

Leave a Reply

Your email address will not be published. Required fields are marked *