What Is Servlet?

A servlet is a Java technology that is managed by a container called a servlet engine. It generates dynamic content and interacts with the client through Request and Response. Servlet extends the functionality of a web server.

Though servlets can respond to many types of requests, they generally implement web containers for hosting any website on web server. Therefore, it is qualified as a server-side servlet web API.

What Is JSP?

JSP is a collection of technologies developed by Sun Microsystems. It is used to develop web pages by inserting Java code into the HTML pages by making special JSP tags. It can consist of either HTML or XML (combination of both is also possible) with JSP actions and commands. The full form of JSP is Java Server Pages.


Why use Servlet?

Why use JSP?

Servlet Life Cycle

Servlet Life Cycle

Start: Execution of servlet begins.

2) Loading & instantiation void init(): It is called when servlet is first loaded. This method lets you initialize servlet.

3) Initialized void service(): The purpose of this method is to serve a request. You can call it as many times as you like.

4) Handling request and destroying servlet: Java application must be first determined what code is needed to execute the request URL to provide a response. To destroy servlet Void destroy method is used at the end of servlet life cycle.

5) End of Request Thread: When service() finishes its task, either the thread ends or returns to the thread pool that is managed by servlet contaier.

6) End: Servlet lifecycle finishes.

7): Stop: Servlet stop executing.

JSP Life Cycle

JSP Life Cycle

Difference between a Servlet and JSP

Advantages of Servlet

Advantages of JSP

This Information is contributed by :

· Vilin Bidwai

· Hrushikesh Borde

· Saurabh Chaudhari

· Amogh Chothe

Student at Vishwakarma Institute of Technology studying MCA

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store