Ans :
Java Server Pages (JSP) is a web technology that helps software developers to create dynamic
content based web pages. Unlike a plain HTML page, which contains static content that
always remains the same but in JSP; you can change content dynamically with the help of
Java Bean and JSP elements. JSP is an extension of Java Servlet because it provides more
functionality than servlet.
Servlet are server side components that services requests from a web server. It is basically a
Java class that runs on a server. Servlet technology is used to create web application. It uses
the Java language. It is runs inside the Java Virtual Machine. Two packages such as
javax.servlet and javax.servlet.http are required for writing a servlet. These two packages
make up the servlet architecture. The javax.servlet package contains the classes and interfaces
that are implemented and extended by all the servlets. Other package javax.servlet.http
contains classes that are required when creating a HTTP specific servlet. All servlets must
implement the Servlet interface, which defines life-cycle methods. The Servlet interface
defines the three most important methods such as init(), service() and destroy() method.
Servlet also possesses all the Java features such as platform independence, high portability,
security and Java database connectivity.
Servlet is very useful for writing server side code but it suffer from some disadvantages. In
particular, writing HTML code with plenty of out.println() statements (println() is a method
of system.out object to display string which is passed to it), it is very tedious and error prone
and also software developers has to take on dual roles of developing application logic and
designing web pages. JSP is designed to address these disadvantages.
Servlet is very useful for writing server side code but it suffer from some disadvantages. In
particular, writing HTML code with plenty of out.println() statements (println() is a method
of system.out object to display string which is passed to it), it is very tedious and error prone
and also software developers has to take on dual roles of developing application logic and
designing web pages. JSP is designed to address these disadvantages.
A Java Server Page contains HTML tags as well as JSP elements. The JSP elements are basic
building blocks of the page. The JSP elements are easier
to maintain than the servlet. A JSP page contains a very
simple structure that makes it easy for developers to write
JSP code and also easy for servlet engine to translate the
page into a corresponding servlet. In addition to html
tags, a JSP page consists of directives, scripting elements,
scriptlets and action elements. Each of these elements can
use either JSP syntax or they can be expressed in XML
syntax but you cannot intermix the two. For this problem,
you can use the include mechanism to insert file that may use different syntax.
It allows programmers to insert the Java code directly into the JSP file that makes the
development process easier.
JSP support element based dynamic content that allows programmers to develop
custom tags libraries to satisfy application needs.
Content and display logic are separated
JSP pages can be used in conjunction with servlet that handle business logic.