This tutorial shows you what is servlet and JSP with its different and how it works with a web application. When Web began to be used for delivering services, Common Gateway Interface (CGI) server-side scripts were the main technology used to generate dynamic content.
Since CGI scripting technology had many shortcomings like platform dependence and lack of scalability. To overcome these limitations, Java Servlet technology was created as a portable way to provide dynamic, user-oriented content.
A servlet is a Java programming language used to create a request-response programming model. Although servlets can respond to any type of request, they are commonly used to HTTP-specific request.
Servlet Technology uses two main packages to handle HTTP request response
These packages provide interfaces and classes for writing servlet programming to handle GET and POST HTTP request.
You can download the jar from
what is servlet
Java Servlets are programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server.
What is JSP
JavaServer Pages (JSP) is a technology for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>.
Difference between JSP and servlet
Servlet is HTML in Java whereas JSP is java in HTML.
JSP can be compiled into Java Servlets
JSP is a webpage scripting language that can generate dynamic content while Servlets are Java programs that are already compiled which also creates dynamic web content
In MVC, JSP acts as a view and servlet act as a controller.
which is better JSP or servlet
JSP is preferred When you have more stuff to do with design part.
Servlet is preferred for creating communication between design and Business layer.