SlideShare une entreprise Scribd logo
1  sur  34
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.
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.
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

Contenu connexe

Similaire à Servlet.pptx (20)

Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Servlet classnotes
Servlet classnotesServlet classnotes
Servlet classnotes
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
 
IP UNIT III PPT.pptx
 IP UNIT III PPT.pptx IP UNIT III PPT.pptx
IP UNIT III PPT.pptx
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Presentation on java servlets
Presentation on java servletsPresentation on java servlets
Presentation on java servlets
 
Java servlets
Java servletsJava servlets
Java servlets
 
Servlets api overview
Servlets api overviewServlets api overview
Servlets api overview
 
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
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
 
Servlets
ServletsServlets
Servlets
 
Unit5 servlets
Unit5 servletsUnit5 servlets
Unit5 servlets
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
 
Servlets
ServletsServlets
Servlets
 
Servlets
ServletsServlets
Servlets
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 
Major project report
Major project reportMajor project report
Major project report
 

Dernier

Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptxrouholahahmadi9876
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxMuhammadAsimMuhammad6
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 

Dernier (20)

Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 

Servlet.pptx