SlideShare a Scribd company logo
Servlets Overview
Agenda
• Introduction to Java Servlets
• Servlet Life Cycle
• Describe web applications, CGI, and the role of Java
• Describe benefits of Java servlet technology
• Create a simple Java Servlet
Introduction to Java Servlets
• Read explicit data sent by client (form data)
• Read implicit data sent by client
(request headers)
• Generate the results
• Send the explicit data back to client (HTML)
• Send the implicit data to client
(status codes and response headers)
Servlets Overview(cont.)
Servlets LifeCycle
• A servlet passes through the following stages in its life.
- Initialize
- Service
- Destroy
Servlet’s Life Cycle (Cont)
Characteristic of Init() stage
• Executed once, when the servlet gets loaded for the first time
• Not called for each client request
• The above two points make it an ideal place to perform the
startup tasks which are done in constructor in a normal class.
Characteristic of service() stage
• service() method is the engine of the servlet
• It is executed per request in a separate Thread
• Hence faster and efficient than CGI
• It is an important method to be overridden in GenericServlet
Benefits of Servlets
• Efficient
- Servlets are light weight java threads and not a process like CGI
- For each request there would be a n no of threads for n
no of requests but only a single Object of a Servlet
class
- When CGI finishes handling request the program terminates making
difficult to cache computations ,keep connection open etc
- Servlets remain in the memory even after the response is complete.
Benefits of Servlets
• Convenient
- Servlets have an extensive infrastructure for
• Parsing and decoding
• Reading and setting http headers
• Handling cookies
• Tracking sessions
- In CGI we have to depend on Perl for such tasks
Benefits of Servlets
• Powerful
- Servlets support several capabilities like
• Communicating with Web Server
• Translate relative URL’s to concrete Path
• Sharing data
• Connection Pooling and optimization
- In CGI we have to user server specific API
Benefits of Servlets
• Portability
- Servlets are written in java and can be deployed in Multiple Servers
• Secure
- Being written entirely in java.
- Does not rely on O/S shell as CGI
Summary
• Demonstrate a simple Servlet example
• Overview the Life cycle of a servlet
• Benefits of Servlet compared to CGI

More Related Content

What's hot (20)

PPTX
Java architecture for xml binding
Kiran Gajbhiye
 
PPTX
Express yourself
Yaniv Rodenski
 
PPT
Implementing portlets using Web Scripts
Piergiorgio Lucidi
 
PPTX
Alfresco Summit 2014 - Crafter CMS - Case European Bank
Piergiorgio Lucidi
 
PPTX
Node ts1
Yaniv Rodenski
 
PPTX
Signal rity1
Yaniv Rodenski
 
PDF
Implementing advanced integration patterns with WSO2 ESB
WSO2
 
PPTX
Log management system for Microservices
Võ Duy Tuấn
 
PDF
Alfresco WebScript Connector for Apache ManifoldCF
Piergiorgio Lucidi
 
PPTX
AngularJS
Yogesh L
 
PDF
Introduction to JCA and MDB
Kenji HASUNUMA
 
PPTX
Rest assured
Yaniv Rodenski
 
PPTX
ASP.NET MVC overview
Vladislav Hadzhiyski
 
PPTX
Introduction to ASP.NET 5
mbaric
 
PPTX
MongoDB and MongoMK Source Event
Yuval Ararat
 
PPTX
Web forms Overview Presentation
Vladislav Hadzhiyski
 
PDF
WSO2Con USA 2015: Building Web Apps with Reusable UI Components and Composition
WSO2
 
PPTX
Mule ESB Intro
Noga Manela
 
PDF
Restful风格ž„web服务架构
Benjamin Tan
 
PPT
WSO2-ESB - The backbone of Enterprise Integration
Kasun Indrasiri
 
Java architecture for xml binding
Kiran Gajbhiye
 
Express yourself
Yaniv Rodenski
 
Implementing portlets using Web Scripts
Piergiorgio Lucidi
 
Alfresco Summit 2014 - Crafter CMS - Case European Bank
Piergiorgio Lucidi
 
Node ts1
Yaniv Rodenski
 
Signal rity1
Yaniv Rodenski
 
Implementing advanced integration patterns with WSO2 ESB
WSO2
 
Log management system for Microservices
Võ Duy Tuấn
 
Alfresco WebScript Connector for Apache ManifoldCF
Piergiorgio Lucidi
 
AngularJS
Yogesh L
 
Introduction to JCA and MDB
Kenji HASUNUMA
 
Rest assured
Yaniv Rodenski
 
ASP.NET MVC overview
Vladislav Hadzhiyski
 
Introduction to ASP.NET 5
mbaric
 
MongoDB and MongoMK Source Event
Yuval Ararat
 
Web forms Overview Presentation
Vladislav Hadzhiyski
 
WSO2Con USA 2015: Building Web Apps with Reusable UI Components and Composition
WSO2
 
Mule ESB Intro
Noga Manela
 
Restful风格ž„web服务架构
Benjamin Tan
 
WSO2-ESB - The backbone of Enterprise Integration
Kasun Indrasiri
 

Similar to Advance java session 2 (20)

PPT
Presentation on java servlets
Aamir Sohail
 
PPTX
Chapter 3 servlet & jsp
Jafar Nesargi
 
PPTX
servlets sessions and cookies, jdbc connectivity
snehalatha790700
 
PPTX
Wt unit 3
team11vgnt
 
PPTX
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
VENKATESHBHAT25
 
PPTX
Servlets-UNIT3and introduction to servlet
RadhikaP41
 
PPT
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
sindhu991994
 
PPTX
nagavarthini ppt.pptx
PooraniBalamurugan3
 
PPTX
JAVA
rithika858339
 
PPTX
WEB TECHNOLOGY Unit-3.pptx
karthiksmart21
 
PPTX
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
ssuser4f7d71
 
PPTX
Servlet session 1
Anuj Singh Rajput
 
PPTX
Servlet.pptx
Senthil Kumar
 
PPTX
Servlet.pptx
SenthilKumar571813
 
PPT
Servlet (1) also contains code to create it.ppt
juhishrivastava25
 
PDF
Java servlets
Mukesh Tekwani
 
PPTX
CS8651 IP Unit 3.pptx
Vigneshkumar Ponnusamy
 
PDF
SERVER SIDE PROGRAMMING
Prabu U
 
PPT
Servlet.ppt
MouDhara1
 
PPT
Servlet.ppt
kstalin2
 
Presentation on java servlets
Aamir Sohail
 
Chapter 3 servlet & jsp
Jafar Nesargi
 
servlets sessions and cookies, jdbc connectivity
snehalatha790700
 
Wt unit 3
team11vgnt
 
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
VENKATESHBHAT25
 
Servlets-UNIT3and introduction to servlet
RadhikaP41
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
sindhu991994
 
nagavarthini ppt.pptx
PooraniBalamurugan3
 
WEB TECHNOLOGY Unit-3.pptx
karthiksmart21
 
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
ssuser4f7d71
 
Servlet session 1
Anuj Singh Rajput
 
Servlet.pptx
Senthil Kumar
 
Servlet.pptx
SenthilKumar571813
 
Servlet (1) also contains code to create it.ppt
juhishrivastava25
 
Java servlets
Mukesh Tekwani
 
CS8651 IP Unit 3.pptx
Vigneshkumar Ponnusamy
 
SERVER SIDE PROGRAMMING
Prabu U
 
Servlet.ppt
MouDhara1
 
Servlet.ppt
kstalin2
 
Ad

More from Smita B Kumar (18)

PPTX
Advance java session 19
Smita B Kumar
 
PPTX
Advance java session 18
Smita B Kumar
 
PPTX
Advance java session 17
Smita B Kumar
 
PPTX
Advance java session 16
Smita B Kumar
 
PPTX
Advance java session 15
Smita B Kumar
 
PPTX
Advance java session 14
Smita B Kumar
 
PPTX
Advance java session 13
Smita B Kumar
 
PPTX
Advance java session 12
Smita B Kumar
 
PPTX
Advance java session 11
Smita B Kumar
 
PPTX
Advance java session 10
Smita B Kumar
 
PPTX
Advance java session 9
Smita B Kumar
 
PPTX
Advance java session 8
Smita B Kumar
 
PPTX
Advance java session 7
Smita B Kumar
 
PPTX
Advance java session 6
Smita B Kumar
 
PPTX
Advance java session 5
Smita B Kumar
 
PPTX
Advance java session 4
Smita B Kumar
 
PPTX
Advance java session 3
Smita B Kumar
 
PPTX
01 introduction to struts2
Smita B Kumar
 
Advance java session 19
Smita B Kumar
 
Advance java session 18
Smita B Kumar
 
Advance java session 17
Smita B Kumar
 
Advance java session 16
Smita B Kumar
 
Advance java session 15
Smita B Kumar
 
Advance java session 14
Smita B Kumar
 
Advance java session 13
Smita B Kumar
 
Advance java session 12
Smita B Kumar
 
Advance java session 11
Smita B Kumar
 
Advance java session 10
Smita B Kumar
 
Advance java session 9
Smita B Kumar
 
Advance java session 8
Smita B Kumar
 
Advance java session 7
Smita B Kumar
 
Advance java session 6
Smita B Kumar
 
Advance java session 5
Smita B Kumar
 
Advance java session 4
Smita B Kumar
 
Advance java session 3
Smita B Kumar
 
01 introduction to struts2
Smita B Kumar
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
July Patch Tuesday
Ivanti
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
July Patch Tuesday
Ivanti
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Python basic programing language for automation
DanialHabibi2
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 

Advance java session 2

  • 2. Agenda • Introduction to Java Servlets • Servlet Life Cycle • Describe web applications, CGI, and the role of Java • Describe benefits of Java servlet technology • Create a simple Java Servlet
  • 3. Introduction to Java Servlets • Read explicit data sent by client (form data) • Read implicit data sent by client (request headers) • Generate the results • Send the explicit data back to client (HTML) • Send the implicit data to client (status codes and response headers)
  • 5. Servlets LifeCycle • A servlet passes through the following stages in its life. - Initialize - Service - Destroy
  • 7. Characteristic of Init() stage • Executed once, when the servlet gets loaded for the first time • Not called for each client request • The above two points make it an ideal place to perform the startup tasks which are done in constructor in a normal class.
  • 8. Characteristic of service() stage • service() method is the engine of the servlet • It is executed per request in a separate Thread • Hence faster and efficient than CGI • It is an important method to be overridden in GenericServlet
  • 9. Benefits of Servlets • Efficient - Servlets are light weight java threads and not a process like CGI - For each request there would be a n no of threads for n no of requests but only a single Object of a Servlet class - When CGI finishes handling request the program terminates making difficult to cache computations ,keep connection open etc - Servlets remain in the memory even after the response is complete.
  • 10. Benefits of Servlets • Convenient - Servlets have an extensive infrastructure for • Parsing and decoding • Reading and setting http headers • Handling cookies • Tracking sessions - In CGI we have to depend on Perl for such tasks
  • 11. Benefits of Servlets • Powerful - Servlets support several capabilities like • Communicating with Web Server • Translate relative URL’s to concrete Path • Sharing data • Connection Pooling and optimization - In CGI we have to user server specific API
  • 12. Benefits of Servlets • Portability - Servlets are written in java and can be deployed in Multiple Servers • Secure - Being written entirely in java. - Does not rely on O/S shell as CGI
  • 13. Summary • Demonstrate a simple Servlet example • Overview the Life cycle of a servlet • Benefits of Servlet compared to CGI