SlideShare a Scribd company logo
U18CSI6201
INTERNET & WEB PROGRAMMING
SERVLETS
V.SENTHIL KUMAR
Department of CSE
COURSE
OUTCOMES
CO1: DESIGN A WEBSITE USING HTML (K5, S3)
CO2: Apply Cascading Style Sheet to design a HTML
Webpage (K3, S2)
CO3: Develop a HTML form and validate it using Java
Script (K5, S2)
CO4: Develop web application using JSP, Servlet (K5,
S3)
CO5: Develop an XML document and validate it using
SCHEMA (K5, S2)
AGENDA
WHAT IS
SERVLET?
ADVANTAGES SERVLET
ARCHITECTURE
SERVLET TASKS SERVLET
PACKAGE
SERVLET LIFE
CYCLE
What are
Servlets?
• Java Servlets are programs that
run on a Web or Application
server.
• Act as a middle layer between a
requests coming from a Web
browser or other HTTP client and
databases or applications on the
HTTP server.
• Implemented using the Common
Gateway Interface (CGI).
Servlet
CGI
(Common
Gateway
Interface)
Disadvantages of
CGI
• There are many problems in CGI technology:
1.If the number of clients increases, it takes
more time for sending the response.
2.For each request, it starts a process, and the
web server is limited to start processes.
3.It uses platform dependent language
e.g. C, C++, perl.
Advantages
of Servlet
Advantages
of servlet
Better performance: because it creates
a thread for each request, not process.
Portability: because it uses Java
language.
Robust: JVM manages Servlets, so we
don't need to worry about the memory
leak, garbage collection, etc.
Secure: because it uses java language.
Servlets
offer several
advantages
• Performance is significantly better.
• Servlets execute within the address
space of a Web server.
• Servlets are platform-independent
• Java security manager on the server
enforces a set of restrictions to protect
the resources on a server machine.
• The full functionality of the Java class
libraries is available to a servlet.
Servlet.pptx
Servlets
Architecture
Servlet Container
• It provides the runtime environment for JavaEE
(j2ee) applications.
• The client/user can request only a static
WebPages from the server. If the user wants to
read the web pages as per input then the
servlet container is used in java.
Servlet
Container
Servlet
Container
States
Standalone: It is typical Java-based servers in which the
servlet container and the web servers are the integral
part of a single program. For example:- Tomcat running
by itself
In-process: It is separated from the web server, because
a different program runs within the address space of the
main server as a plug-in. For example:- Tomcat running
inside the JBoss.
Out-of-process: The web server and servlet container
are different programs which are run in a different
process. For performing the communications between
them, web server uses the plug-in provided by the
servlet container.
Server: Web vs.
Application
• Server is a device or a computer program that
accepts and responds to the request made by
other program, known as client. It is used to
manage the network resources and for running
the program or software that provides services.
• There are two types of servers:
1.Web Server
2.Application Server
Web
Server
Web server contains only web or servlet container. It can be used for
servlet, jsp, struts, jsf etc. It can't be used for EJB.
It is a computer where the web content can be stored. In general
web server can be used to host the web sites but there also used
some other web servers also such as FTP, email, storage, gaming etc.
Examples of Web Servers are: Apache Tomcat and Resin.
Generating response by using the script and communicating with
database.
Sending file to the client associated with the requested URL.
Web Server
Application
Server
• Application server contains Web and EJB containers.
It can be used for servlet, jsp, struts, jsf, ejb etc. It is a
component based product that lies in the middle-tier of
a server centric architecture.
• It provides the middleware services for state
maintenance and security, along with persistence and
data access. It is a type of server designed to install,
operate and host associated services and applications
for the IT services, end users and organizations.
Application
Server
Servlets Tasks
Read the explicit
data sent by the
clients (browsers).
1
Read the implicit
HTTP request data
sent by the clients
(browsers).
2
Process the data
and generate the
results.
3
Send the explicit
data (i.e., the
document) to the
clients (browsers).
4
Send the implicit
HTTP response to
the clients
(browsers).
5
Servlet API
• The javax.servlet and javax.servlet.http
packages represent interfaces and classes for
servlet api.
• The javax.servlet package contains many
interfaces and classes that are used by the
servlet or web container. These are not
specific to any protocol.
• The javax.servlet.http package contains
interfaces and classes that are responsible for
http requests only.
Interfaces in
javax.servlet
package
1.Servlet
2.ServletRequest
3.ServletResponse
4.RequestDispatcher
5.ServletConfig
6.ServletContext
7.SingleThreadModel
8.Filter
9.FilterConfig
10.FilterChain
11.ServletRequestListener
12.ServletRequestAttributeListener
13.ServletContextListener
14.ServletContextAttributeListener
Classes in
javax.servle
t package
1.GenericServlet
2.ServletInputStream
3.ServletOutputStream
4.ServletRequestWrapper
5.ServletResponseWrapper
6.ServletRequestEvent
7.ServletContextEvent
8.ServletRequestAttributeEvent
9.ServletContextAttributeEvent
10.ServletException
11.UnavailableException
Interfaces in
javax.servlet.http
package
1.HttpServletRequest
2.HttpServletResponse
3.HttpSession
4.HttpSessionListener
5.HttpSessionAttributeListener
6.HttpSessionBindingListener
7.HttpSessionActivationListener
8.HttpSessionContext
Classes in
javax.servlet.http
package
1.HttpServlet
2.Cookie
3.HttpServletRequestWrapper
4.HttpServletResponseWrapper
5.HttpSessionEvent
6.HttpSessionBindingEvent
7.HttpUtils
Servlets -
Life Cycle
A servlet life cycle can be defined as the entire process from its
creation till the destruction. The following are the paths followed
by a servlet.
The servlet is initialized by calling the init() method.
The servlet calls service() method to process a client's request.
The servlet is terminated by calling the destroy() method.
Finally, servlet is garbage collected by the garbage collector of
the JVM.
The init() Method
• The init method is called only once. It is
called only when the servlet is created,
and not called for any user requests
afterwards. So, it is used for one-time
initializations, just as with the init method
of applets.
The service()
Method
• The service() method is the main method to perform
the actual task. The servlet container (i.e. web server)
calls the service() method to handle requests coming
from the client( browsers) and to write the formatted
response back to the client.
• The service() method checks the HTTP request type
(GET, POST, PUT, DELETE, etc.) and calls doGet,
doPost, doPut, doDelete, etc. methods as
appropriate.
Servlet.pptx
doGet() &
doPost()
The destroy()
Method
• The destroy() method is called only once at the end of
the life cycle of a servlet.
• This method gives your servlet a chance to close
database connections, halt background threads, write
cookie lists or hit counts to disk, and perform other
such cleanup activities.
Architecture
Diagram
Architecture
First the HTTP requests
coming to the server are
delegated to the servlet
container.
1
The servlet container loads
the servlet before invoking
the service() method.
2
Then the servlet container
handles multiple requests
by spawning multiple
threads, each thread
executing the service()
method of a single instance
of the servlet.
3
Ad

More Related Content

Similar to Servlet.pptx (20)

Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 
Java Servlet
Java ServletJava Servlet
Java Servlet
Yoga Raja
 
Servlets
ServletsServlets
Servlets
Sasidhar Kothuru
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
Tanmoy Barman
 
SERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptxSERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptx
ARUNKUMARM230658
 
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
VENKATESHBHAT25
 
Servlet classnotes
Servlet classnotesServlet classnotes
Servlet classnotes
Vasanti Dutta
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
MattMarino13
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
ssuser92282c
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
SachinSingh217687
 
Presentation on java servlets
Presentation on java servletsPresentation on java servlets
Presentation on java servlets
Aamir Sohail
 
spring Boot Tutorial Part 1(JPA&Hibernate)
spring Boot Tutorial Part 1(JPA&Hibernate)spring Boot Tutorial Part 1(JPA&Hibernate)
spring Boot Tutorial Part 1(JPA&Hibernate)
abdelr7man3mad2004
 
Java servlets
Java servletsJava servlets
Java servlets
Mukesh Tekwani
 
Servlets api overview
Servlets api overviewServlets api overview
Servlets api overview
ramya marichamy
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
sindhu991994
 
SERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servletsSERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Servlets-UNIT3and introduction to servlet
Servlets-UNIT3and introduction to servletServlets-UNIT3and introduction to servlet
Servlets-UNIT3and introduction to servlet
RadhikaP41
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 
Java Servlet
Java ServletJava Servlet
Java Servlet
Yoga Raja
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
Tanmoy Barman
 
SERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptxSERVLET in web technolgy engineering.pptx
SERVLET in web technolgy engineering.pptx
ARUNKUMARM230658
 
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
VENKATESHBHAT25
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
MattMarino13
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
ssuser92282c
 
Presentation on java servlets
Presentation on java servletsPresentation on java servlets
Presentation on java servlets
Aamir Sohail
 
spring Boot Tutorial Part 1(JPA&Hibernate)
spring Boot Tutorial Part 1(JPA&Hibernate)spring Boot Tutorial Part 1(JPA&Hibernate)
spring Boot Tutorial Part 1(JPA&Hibernate)
abdelr7man3mad2004
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
sindhu991994
 
SERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servletsSERVLETS (2).pptxintroduction to servlet with all servlets
SERVLETS (2).pptxintroduction to servlet with all servlets
RadhikaP41
 
Servlets-UNIT3and introduction to servlet
Servlets-UNIT3and introduction to servletServlets-UNIT3and introduction to servlet
Servlets-UNIT3and introduction to servlet
RadhikaP41
 

Recently uploaded (20)

Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Ad

Servlet.pptx