By this tutorial,we can learn What is JSP , why use JSP , Advantages of JSP
- JSP Stands for Java Server Pages. JSP is an
alternative technology for Servlet.
- A JSP page consists of HTML tags and JSP tags.
It provides some additional features such as Expression Language,
Custom Tag etc.
- Servlet can be viewed as "HTML inside Java",
which is better for implementing business logic - as it is Java
dominant. JSP, on the other hand, is "Java inside HTML", which is
superior for creating presentation - as it is HTML dominant.
- In a typical Model-View-Control (MVC)
application, Servlet are often used for the Controller (C), which
involves complex programming logic. JSPs are often used for the
View (V), which mainly deals with presentation.
Advantages of JSP
- Separation of static and dynamic contents:
The dynamic contents are generated via programming logic and
inserted into the static template. This greatly simplifies the
creation and maintenance of web contents.
- Extension to Servlet: JSP technology is the
extension to Servlet technology. We can use all the features of
Servlet in JSP. In addition to, we can use implicit objects,
predefined tags, expression language and Custom tags in JSP that
makes JSP development easy.
- Minimize or reduce maintenance and deployment
problems: maintenance is easy because business logic is separated
from presentation logic. Secondly, If JSP page is modified, we
don't need to recompile and redeploy the project. The Servlet code
needs to be updated and recompiled if we have to change the look
and feel of the application.
Difference between JSP and Servlet
1. A Servlet is a server-side program
2. Executes inside
a Web server, such as Tomcat.
3. Receives HTTP requests
from users and provides HTTP responses
4. Written in
Java, with a few additional APIs specific to this kind of
5. In MVC architecture Servlet acts as
1. JSP is an interface on top of Servlets
2. A JSP
program is compiled into a Java Servlet before execution
3. Easier to write than Servlet as it is similar to HTML.
4. Can make use of JavaBeans also.
5. In MVC
architecture JSP acts as view.