SlideShare a Scribd company logo
SESSION – 1
By→ Anuj Kumar Singh
Introduction to Servlet
1. Servlets are the Java programs that runs on the Java-enabled web
server or application server. They are used to handle the request
obtained from the web server, process the request, produce the
response, then send response back to the web server.
2. Properties of Servlets :
a. Servlets work on the server-side.
b. Servlets are capable of handling complex requests obtained from
web server.
Execution of Servlets :
Execution of Servlets involves six basic steps:
1. The clients send the request to the web server.
2. The web server receives the request.
3. The web server passes the request to the corresponding servlet.
4. The servlet processes the request and generates the response in the
form of output.
5. The servlet sends the response back to the web server.
6. The web server sends the response back to the client and the client
browser displays it on the screen.
Servlet Architecture
1. The server-side extensions are
technologies that are used to create
dynamic Web pages.
2. To provide the facility of dynamic Web
pages, Web pages need a container
or Web server.
3. To meet this requirement, independent
Web server providers APIs.
4. These APIs allow us to build programs
that can run with a Web server. Java
Servlet is also one of the component
APIs of Java Platform Enterprise
Edition which sets standards for
creating dynamic Web applications in
Java.
The Servlet technology is similar to other Web server extensions such
as Common Gateway Interface (CGI) scripts and Hypertext
Preprocessor (PHP). However, Java Servlets are more acceptable since
they solve the limitations of CGI such as low performance and low
degree scalability.
What is CGI (Common Gateway Interface)?
1. CGI is actually an external application which is written by using any of the
programming languages like C or C++ and this is responsible for processing
client requests and generating dynamic content.
2. CGI Working
a. It first locates the requested web page i.e. the required CGI application
using URL.
b. It then creates a new process to service the client’s request.
c. Invokes the CGI application within the process and passes the request
information to the server.
d. Collects the response from CGI application.
e. Destroys the process, prepares the HTTP response and sends it to the
client.
So, in CGI server has to create and
destroy the process for every request. It’s
easy to understand that this approach is
applicable for handling few clients but as
the number of clients increases, the
workload on the server increases and so
the time taken to process requests
increases.
Difference between Servlet & CGI
SERVLET CGI (COMMON GATEWAY INTERFACE)
Servlets are portable and efficient.
CGI is not portable
In Servlets, sharing of data is possible. In CGI, sharing of data is not possible.
Servlets can directly communicate with the web
server.
CGI cannot directly communicate with the web
server.
Servlets are less expensive than CGI. CGI are more expensive than Servlets.
Servlets can handle the cookies.
CGI cannot handle the cookies.
Servlets API’s:
Servlets are build from two packages:
1. javax.servlet(Basic)
2. javax.servlet.http(Advance)
Classes and Interfaces present in these packages are:
COMPONENT TYPE PACKAGE
Servlet Interface javax.servlet.*
ServletRequest Interface javax.servlet.*
ServletResponse Interface javax.servlet.*
GenericServlet Class javax.servlet.*
HttpServlet Class javax.servlet.http.*
HttpServletRequest Interface javax.servlet.http.*
HttpServletResponse Interface javax.servlet.http.*
Filter Interface javax.servlet.*
ServletConfig Interface javax.servlet.*
Advantages of a Java Servlet
1. Servlet is faster than CGI as it doesn’t involve the creation of a new
process for every new request received.
2. Servlets as written in Java are platform independent.
3. Removes the overhead of creating a new process for each request as
Servlet doesn’t run in a separate process. There is only a single
instance which handles all requests concurrently. This also saves the
memory and allows a Servlet to easily manage client state.
4. It is a server-side component, so Servlet inherits the security provided
by the Web server.
5. The API designed for Java Servlet automatically acquires the
advantages of Java platform such as platform independent and
portability. In addition, it obviously can use the wide range of APIs
created on Java platform such as JDBC to access the database.
Servlet Container
1. Also known as Servlet engine that provide run time environment for Java
Servlet components.
2. Services provided by the Servlet container :
a. Network Services : Loads a Servlet class. The loading may be from a local file
system, a remote file system or other network services. It provides the network
services over which the request and response are sent.
b. Encode and Decode MIME based messages : Provides the service of
decoding and encoding MIME-based messages.
c. Manage Servlet container : Manages the lifecycle of a Servlet.
d. Resource management : Manages the static and dynamic resources, such as
HTML files, Servlets and JSP pages.
e. Security Service : Handles authentication and authorization of resource access.
f. Session Management : Maintains a session by appending a session ID to the
URL path.
Servlet   session 1

More Related Content

What's hot (20)

PPTX
Server Side Programming
Milan Thapa
 
PPTX
J servlets
reddivarihareesh
 
PDF
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
WebStackAcademy
 
PPT
Server side programming
Sayed Ahmed
 
PPTX
Servlet api & servlet http package
renukarenuka9
 
PPTX
Java servlets and CGI
lavanya marichamy
 
PPTX
Advanced java+JDBC+Servlet
Anuj Singh Rajput
 
PDF
Android HTTP Service
Eduardo Silva Pereira
 
PDF
Web Developer Tools
Mindfire Solutions
 
PPTX
Servlets
ZainabNoorGul
 
PPTX
Node js Chapter-2
Talentica Software
 
PDF
Clustering Multiple Instances in Cold Fusion
Mindfire Solutions
 
PPTX
java Servlet technology
Tanmoy Barman
 
PPT
Java - Servlet - Mazenet Solution
Mazenetsolution
 
PPTX
video conference (peer to peer)
mohamed amr
 
PPTX
Testing Microservices
Anil Allewar
 
PPTX
Servlet in java , java servlet , servlet servlet and CGI, API
PRIYADARSINISK
 
PPTX
Servlet
Priyanka Pradhan
 
PPTX
Javax.servlet,http packages
vamsi krishna
 
PPTX
Jsp and Servlets
Raghu nath
 
Server Side Programming
Milan Thapa
 
J servlets
reddivarihareesh
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
WebStackAcademy
 
Server side programming
Sayed Ahmed
 
Servlet api & servlet http package
renukarenuka9
 
Java servlets and CGI
lavanya marichamy
 
Advanced java+JDBC+Servlet
Anuj Singh Rajput
 
Android HTTP Service
Eduardo Silva Pereira
 
Web Developer Tools
Mindfire Solutions
 
Servlets
ZainabNoorGul
 
Node js Chapter-2
Talentica Software
 
Clustering Multiple Instances in Cold Fusion
Mindfire Solutions
 
java Servlet technology
Tanmoy Barman
 
Java - Servlet - Mazenet Solution
Mazenetsolution
 
video conference (peer to peer)
mohamed amr
 
Testing Microservices
Anil Allewar
 
Servlet in java , java servlet , servlet servlet and CGI, API
PRIYADARSINISK
 
Javax.servlet,http packages
vamsi krishna
 
Jsp and Servlets
Raghu nath
 

Similar to Servlet session 1 (20)

PDF
Java servlets
Mukesh Tekwani
 
PPTX
WEB TECHNOLOGY Unit-3.pptx
karthiksmart21
 
PPTX
nagavarthini ppt.pptx
PooraniBalamurugan3
 
PPTX
Chapter 3 servlet & jsp
Jafar Nesargi
 
PPTX
UNIT - 5.pptx Servlets And Database Connectivity
bmit1
 
PDF
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
pkaviya
 
PPTX
Servlets-UNIT3and introduction to servlet
RadhikaP41
 
PDF
Enterprise Java, Servlet, JDBC and JSP.pdf
PokemonSpyk
 
PPTX
Servlet.pptx
Senthil Kumar
 
PPTX
Servlet.pptx
SenthilKumar571813
 
PPT
Servlet programming
Mallikarjuna G D
 
PPTX
JAVA
rithika858339
 
PPTX
J2ee servlet
vinoth ponnurangam
 
PPT
Ppt for Online music store
ADEEBANADEEM
 
PPTX
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
PPT
Servlet programming
Mallikarjuna G D
 
PPTX
Java Servlet
Yoga Raja
 
PPT
Programming Server side with Sevlet
backdoor
 
PPTX
Servlets
Rajkiran Mummadi
 
PDF
Adv java unit 4 M.Sc CS.pdf
KALAISELVI P
 
Java servlets
Mukesh Tekwani
 
WEB TECHNOLOGY Unit-3.pptx
karthiksmart21
 
nagavarthini ppt.pptx
PooraniBalamurugan3
 
Chapter 3 servlet & jsp
Jafar Nesargi
 
UNIT - 5.pptx Servlets And Database Connectivity
bmit1
 
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
pkaviya
 
Servlets-UNIT3and introduction to servlet
RadhikaP41
 
Enterprise Java, Servlet, JDBC and JSP.pdf
PokemonSpyk
 
Servlet.pptx
Senthil Kumar
 
Servlet.pptx
SenthilKumar571813
 
Servlet programming
Mallikarjuna G D
 
J2ee servlet
vinoth ponnurangam
 
Ppt for Online music store
ADEEBANADEEM
 
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Servlet programming
Mallikarjuna G D
 
Java Servlet
Yoga Raja
 
Programming Server side with Sevlet
backdoor
 
Adv java unit 4 M.Sc CS.pdf
KALAISELVI P
 
Ad

More from Anuj Singh Rajput (20)

PPTX
Web technology
Anuj Singh Rajput
 
PPTX
Java script
Anuj Singh Rajput
 
PPTX
Html (hypertext markup language)
Anuj Singh Rajput
 
PPTX
Bootstrap
Anuj Singh Rajput
 
PPTX
Jsp session 13
Anuj Singh Rajput
 
PPTX
Jsp session 12
Anuj Singh Rajput
 
PPTX
Jsp session 11
Anuj Singh Rajput
 
PPTX
Jsp session 10
Anuj Singh Rajput
 
PPTX
Jsp session 9
Anuj Singh Rajput
 
PPTX
Jsp session 8
Anuj Singh Rajput
 
PPTX
Jsp session 7
Anuj Singh Rajput
 
PPTX
Jsp session 6
Anuj Singh Rajput
 
PPTX
Jsp session 5
Anuj Singh Rajput
 
PPTX
Jsp session 4
Anuj Singh Rajput
 
PPTX
Jsp session 3
Anuj Singh Rajput
 
PPTX
Jsp session 2
Anuj Singh Rajput
 
PPTX
Jsp session 1
Anuj Singh Rajput
 
PPTX
Servlet session 14
Anuj Singh Rajput
 
PPTX
Servlet session 13
Anuj Singh Rajput
 
Web technology
Anuj Singh Rajput
 
Java script
Anuj Singh Rajput
 
Html (hypertext markup language)
Anuj Singh Rajput
 
Jsp session 13
Anuj Singh Rajput
 
Jsp session 12
Anuj Singh Rajput
 
Jsp session 11
Anuj Singh Rajput
 
Jsp session 10
Anuj Singh Rajput
 
Jsp session 9
Anuj Singh Rajput
 
Jsp session 8
Anuj Singh Rajput
 
Jsp session 7
Anuj Singh Rajput
 
Jsp session 6
Anuj Singh Rajput
 
Jsp session 5
Anuj Singh Rajput
 
Jsp session 4
Anuj Singh Rajput
 
Jsp session 3
Anuj Singh Rajput
 
Jsp session 2
Anuj Singh Rajput
 
Jsp session 1
Anuj Singh Rajput
 
Servlet session 14
Anuj Singh Rajput
 
Servlet session 13
Anuj Singh Rajput
 
Ad

Recently uploaded (20)

PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PPTX
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
John Keats introduction and list of his important works
vatsalacpr
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPT
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
John Keats introduction and list of his important works
vatsalacpr
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 

Servlet session 1

  • 1. SESSION – 1 By→ Anuj Kumar Singh
  • 2. Introduction to Servlet 1. Servlets are the Java programs that runs on the Java-enabled web server or application server. They are used to handle the request obtained from the web server, process the request, produce the response, then send response back to the web server. 2. Properties of Servlets : a. Servlets work on the server-side. b. Servlets are capable of handling complex requests obtained from web server.
  • 3. Execution of Servlets : Execution of Servlets involves six basic steps: 1. The clients send the request to the web server. 2. The web server receives the request. 3. The web server passes the request to the corresponding servlet. 4. The servlet processes the request and generates the response in the form of output. 5. The servlet sends the response back to the web server. 6. The web server sends the response back to the client and the client browser displays it on the screen.
  • 4. Servlet Architecture 1. The server-side extensions are technologies that are used to create dynamic Web pages. 2. To provide the facility of dynamic Web pages, Web pages need a container or Web server. 3. To meet this requirement, independent Web server providers APIs. 4. These APIs allow us to build programs that can run with a Web server. Java Servlet is also one of the component APIs of Java Platform Enterprise Edition which sets standards for creating dynamic Web applications in Java.
  • 5. The Servlet technology is similar to other Web server extensions such as Common Gateway Interface (CGI) scripts and Hypertext Preprocessor (PHP). However, Java Servlets are more acceptable since they solve the limitations of CGI such as low performance and low degree scalability.
  • 6. What is CGI (Common Gateway Interface)? 1. CGI is actually an external application which is written by using any of the programming languages like C or C++ and this is responsible for processing client requests and generating dynamic content. 2. CGI Working a. It first locates the requested web page i.e. the required CGI application using URL. b. It then creates a new process to service the client’s request. c. Invokes the CGI application within the process and passes the request information to the server. d. Collects the response from CGI application. e. Destroys the process, prepares the HTTP response and sends it to the client.
  • 7. So, in CGI server has to create and destroy the process for every request. It’s easy to understand that this approach is applicable for handling few clients but as the number of clients increases, the workload on the server increases and so the time taken to process requests increases.
  • 8. Difference between Servlet & CGI SERVLET CGI (COMMON GATEWAY INTERFACE) Servlets are portable and efficient. CGI is not portable In Servlets, sharing of data is possible. In CGI, sharing of data is not possible. Servlets can directly communicate with the web server. CGI cannot directly communicate with the web server. Servlets are less expensive than CGI. CGI are more expensive than Servlets. Servlets can handle the cookies. CGI cannot handle the cookies.
  • 9. Servlets API’s: Servlets are build from two packages: 1. javax.servlet(Basic) 2. javax.servlet.http(Advance)
  • 10. Classes and Interfaces present in these packages are: COMPONENT TYPE PACKAGE Servlet Interface javax.servlet.* ServletRequest Interface javax.servlet.* ServletResponse Interface javax.servlet.* GenericServlet Class javax.servlet.* HttpServlet Class javax.servlet.http.* HttpServletRequest Interface javax.servlet.http.* HttpServletResponse Interface javax.servlet.http.* Filter Interface javax.servlet.* ServletConfig Interface javax.servlet.*
  • 11. Advantages of a Java Servlet 1. Servlet is faster than CGI as it doesn’t involve the creation of a new process for every new request received. 2. Servlets as written in Java are platform independent. 3. Removes the overhead of creating a new process for each request as Servlet doesn’t run in a separate process. There is only a single instance which handles all requests concurrently. This also saves the memory and allows a Servlet to easily manage client state. 4. It is a server-side component, so Servlet inherits the security provided by the Web server. 5. The API designed for Java Servlet automatically acquires the advantages of Java platform such as platform independent and portability. In addition, it obviously can use the wide range of APIs created on Java platform such as JDBC to access the database.
  • 12. Servlet Container 1. Also known as Servlet engine that provide run time environment for Java Servlet components. 2. Services provided by the Servlet container : a. Network Services : Loads a Servlet class. The loading may be from a local file system, a remote file system or other network services. It provides the network services over which the request and response are sent. b. Encode and Decode MIME based messages : Provides the service of decoding and encoding MIME-based messages. c. Manage Servlet container : Manages the lifecycle of a Servlet. d. Resource management : Manages the static and dynamic resources, such as HTML files, Servlets and JSP pages. e. Security Service : Handles authentication and authorization of resource access. f. Session Management : Maintains a session by appending a session ID to the URL path.