0% found this document useful (0 votes)
289 views2 pages

UNIT - 5 Difference Between Servlet and JSP

Servlets are server-side Java programs that receive HTTP requests and send HTTP responses. JSPs simplify creating dynamic web pages by allowing Java code and HTML code to be combined in the same file. JSP pages are compiled into servlets before execution, so they have the same lifecycle as servlets but with additional JSP-specific APIs. A key advantage of JSPs is the ability to create custom tags for reusable components.

Uploaded by

mahendra solanki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
289 views2 pages

UNIT - 5 Difference Between Servlet and JSP

Servlets are server-side Java programs that receive HTTP requests and send HTTP responses. JSPs simplify creating dynamic web pages by allowing Java code and HTML code to be combined in the same file. JSP pages are compiled into servlets before execution, so they have the same lifecycle as servlets but with additional JSP-specific APIs. A key advantage of JSPs is the ability to create custom tags for reusable components.

Uploaded by

mahendra solanki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Difference Between Servlet and JSP

SERVLET JSP

A servlet is a server-side program and JSP is an interface on top of Servlets. In another

written purely on Java. way, we can say that JSPs are extension of servlets

to minimize the effort of developers to write User

Interfaces using Java programming.

Servlets run faster than JSP JSP runs slower because it has the transition phase

for converting from JSP page to a Servlet file. Once

it is converted to a Servlet then it will start the

compilation

Executes inside a Web server, such as A JSP program is compiled into a Java servlet

Tomcat before execution. Once it is compiled into a servlet,

it's life cycle will be same as of servlet. But, JSP has

it's own API for the lifecycle.

Receives HTTP requests from users and Easier to write than servlets as it is similar to

provides HTTP responses HTML.

We can not build any custom tags One of the key advantage is we can build custom

tags using JSP API (there is a separate package

available for writing the custom tags) which can be

available as the re-usable components with lot of

flexibility
SERVLET JSP

Servlet has the life cycle methods init(), JSP has the life cycle methods of jspInit(),

service() and destroy() _jspService() and jspDestroy()

Written in Java, with a few additional JSPs can make use of the Javabeans inside the web

APIs specific to this kind of processing. pages

Since it is written in Java, it follows all

the Object Oriented programming

techniques.

In MVC architecture Servlet acts as In MVC architecture JSP acts as view.

controller.

Servlet advantages include: JSP Provides an extensive infrastructure for:

1. Performance : get loaded upon first 1. Tracking sessions.

request and remains in memory 2. Managing cookies.

idenfinately. 3. Reading and sending HTML headers.

2. Simplicity : Run inside controlled 4. Parsing and decoding HTML form data.

server environment. No specific client 5. JSP is Efficient: Every request for a JSP is

software is needed:web broser is enough handled by a simple Java thread

3. Session Management : overcomes 6. JSP is Scalable: Easy integration with other

HTTP's stateless nature backend services

4. Java Technology : network 7. Seperation of roles: Developers, Content

access,Database connectivity, j2ee Authors/Graphic Designers/Web Masters

integration

You might also like