Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Why JSP?

Java Server Pages (JSP) technology is that the Java platform technology for delivering
dynamic content to web clients in a portable, secure, and well-defined way. The Java
Server Pages specification extends the Java Servlet API to supply web application
developers with a strong framework for creating a dynamic web page on the server using
HTML, and XML templates, and Java code, which is secure, fast, and independent of server
platforms. JSP has been built on top of the Servlet API and utilizes Servlet semantics. JSP
has become the well-liked request handler and response mechanism. Although JSP
technology goes to be a strong successor to basic Servlets, they need an evolutionary
relationship and may be utilized in a cooperative and complementary manner.

In the initial days of servlets, sun Microsystems failed to attract ASP programmers towards
servlets. The reasons are:

1. ASP supports tag-based programming, servlet doesn’t support it.


2. To work with servlet string knowledge is required. It is very difficult for an ASP
programmer to learn Java.

To overcome the above problems Sun Microsystems has given a tag-based technology
called JSP having all the features of Servlet. So, any programmer can use JSP without
having strong knowledge of Java/Servlet.

Advantages of JSP over Servlet

JSP technology was designed to simplify the process of creating pages. It simplifies the
process by separating web presentations from web content. JSP is a collection of HTML
tags and JSP tags and Java code. Every JSP page is saved with extension .jsp. This JSP
can be placed in the root folder or WEB-INF. The JSP placed in the root folder is a public
resource and this resource can access by the client directly. The JSP placed inside WEB-
INF is a private resource, which can’t access directly by the client. Client access this
resource using public URL defined inside web.xml.

Servlets are powerful and sometimes they’re a touch cumbersome when it involves
generating complex HTML. Most servlets contain a touch code that handles application
logic and tons of more code that handles output formatting. This can make it difficult to
separate and reuse portions of the code when a special output format is required. For these
reasons, web application developers turn towards JSP as their preferred servlet
environment.

Difference Between JSP and ASP:


1. JSP stands for Java Server Pages is a technology introduced by Sun
microsystems whereas ASP stands for Active Server Pages is a technology
introduced by Microsoft.
2. ASP pages can connect to MYSQL and MS Access databases and also can
connect to other databases with the help of ADO whereas JSP can connect to
any databases loading the appropriate driver when needed.
3. JSP is a technology that helps developers to implement and develop dynamic
web pages, whereas ASP is Microsoft’s server-side script engine for
dynamically generated web pages.
4. With respect to performance perspective, JSP code runs faster than ASP.
5. JSP is mainly used by Apache Tomcat Web Server and mainly implemented
on Linux-based web server and also runs on JBoss and IBM application
server, whereas ASP is mainly based on Microsoft IIS server and is
implemented on windows-based systems.
6. JSP is free of cost whereas ASP is not free and requires a proper license for
usage.
7. JSP mainly works with Java Security Model whereas ASP is mainly based on
the Windows NT Security Architecture Model.

Difference Between JSP and Servlets:

1. If we perform any modifications on the existed Servlets then we have to


perform recompiling and reloading on to the server explicitly whereas if we
perform any modifications on the existed JSP then it is not required to perform
recompilation and reloading because JSP pages are auto compiled and
autoloaded.
2. In JSP business logic is isolated from presentation logic by using JavaBeans,
whereas in Servlet we have to execute everything like business logic and
presentation logic in one servlet file.
3. Session Management is automatically enabled in JSP, whereas in Servlet, by
default session management is disabled, the user needs to enable it explicitly.
4. From a performance perspective, JSP is slower than Servlet because the
initial step is the translation of JSP to java code in the JSP lifecycle and then
compilation.
5. In JSP, packages can be imported anywhere top, middle and bottom,
whereas, in Servlet, every package needs to be imported on top of the
Servlet.
6. JSP is used for displaying output data whereas Servlet plays a controller role
in the MVC pattern.

Difference Between JSP and SSI:

1. JSP is a Java standard technology that enables you to write dynamic, data-
driven pages for your Java web applications whereas SSI is a simple server-
side scripting language exclusively for the World Wide Web.
2. JSP uses servlets instead of a separate program to generate dynamic parts
as well as JSP allows for richer processing of form data. SSI invokes an
existing servlet and its output is inserted whole into a static page.
3. JSP is executed by the container’s JSP servlet whereas SSI is executed by
the webserver engine.
4. JSP is executed only once during JSP compile time whereas SSI is executed
on every request.
5. JSP works in JSP files only whereas SSI works in non-JSP files as well.

Difference Between JSP and HTML:

1. JSP is a technology that helps software developers to create dynamically


generated web pages based on HTML whereas HTML is the standard markup
language for creating web pages and web applications.
2. JSP can generate dynamic content whereas HTML can generate static
content only.
3. JSP can access server-side resources whereas HTML can access client-side
resources.
4. HTML does not allow to place java code inside HTML pages whereas JSP
allows placing Java code inside JSP pages.
5. HTML also does not allow to place a custom tag or third-party tag whereas
JSP allows placing a custom tag or third-party tag.
6. HTML provides emphasis on appearance, semantics, and layout in the
browser whereas JSP can invoke built-in functionality from the server.
7. HTML runs in a web browser whereas JSP runs directly on the Web Server
and local JVM.
8. HTML provides a means to describe the structure of text-based information
whereas JSP provides a dynamic interface for continuously changing data
and dynamically invokes server actions.

Difference Between JSP and JavaScript:

1. JSP is a technology based on Servlet container and Java EE whereas


JavaScript is a scripting language.
2. JSP in integration with HTML can be embedded around the Java code using
Scriptlets whereas JavaScript in integration with HTML can’t be embedded
inside.
3. JSP requires Servlet container-based web or application server to deploy the
JSP web pages whereas JavaScript requires a JavaScript engine to run the
code.
4. JSP is maintained by the Java specification group whereas JavaScript is
maintained by the ECMA TC-39 committee.
5. JSP supports HTTP and FTP WebLogic whereas JavaScript supports only
HTTP.
6. It is difficult to maintain larger projects in JSP whereas in JavaScript it is
easier and flexible to develop large and complex projects.
7. JSP supports all browsers easily whereas JavaScript supports contents in few
browsers depending on the functionalities.
8. JSP will be rendered from the Server Side using servlet technology whereas
JavaScript is available in major browsers in client and server-side
environments.

JSP Application design with MVC

MVC was first described by Xerox in the late 1980s. The purpose of using MVC is to
separate components into three distinct units: The Model, the View, and the Controller. This
is a server-side implementation of a popular MVC design pattern.

The Model is the separation of the way application data is modeled; this is the data layer
that consists of the business logic of the system. It consists of all the data of the application
and represents the state of the application.

The View is from the way it is presented. It is a presentation Layer that normally presents
the UI of the application. It is used to display the data fetched from the controller. It shows
the data on the UI of the application.

The Controller is a separate component to handle the processing in between. It acts as an


interface between the View Layer and the Model Layer. It receives the request from View
Layer and processes it and also does the necessary validation for the request. It intercepts
all the requests from the view layer.

In a server application, we commonly classify the parts of the appliance as business logic,
presentation, and request processing. Business logic is that the term used for the
manipulation of an application’s data, i.e., customer, product, and order information.
Presentation refers to how the appliance is shown to the user, i.e., the position, font, and
size. And finally, request processing is what ties the business logic and presentation parts
together. In MVC terms, the Model corresponds to business logic and data, the View to the
presentation logic, and therefore the Controller to the request processing.

You might also like