NADAR SARASWATHI
COLLEGE OF ARTS AND
SCIENCE
DEPARTMENTOF COMPUTERSCIENCE
BY
K.DIANA DEVI
I M.SC(CS)
Servlet life cycle
Generic Servlet
Road Map
Over view of the life cycle
Birth of a servlet
Life of a servlet
Death of a servlet
Over view of
servleT life cycle
Life of a servlet
 Birth: Create and Intialize the Servlet
 Important method: Init()
 Life: Handle 0 Or more Client Request
 Important method: Service()
 Death: Destroy the Servlet
 Important method: Destroy ()
Birth Of A
Servlet
The init() MethoD
 The Init () Method Is Called When The Servlet Is First Request
By A Browser Request
 It Is Not Called Again For Each Request
 Used For One Time Initialization
Life of a
Servlet
Life of a servlet
 The First Time A Servlet Is Called The Servlet
Is Instantiated And It’s Init() Method is called
 Only One Instance Of The Servlet Is Instantiated
 This One Instance Handles All Browser Requests
Service Method
 Each Time The Servlet Receives A Request For A Servlet The Server
Spawns A New Thread And Calls The Servlet Service () Method
Death of a
Servlet
Death of a servlet
 Before A Server Shuts Down It Will Call The Servlet’s Destroy () Method
 You Can Handle Any Servlet Clean Up Here.
Ex:
Updating log Files
Closing Database Connections
Closing Any Socket Connections
Generic
Servlet
Void int(Servlet Config Config)
-Initializers The Servlet
Void Service (Servlet Request req, Servlet Response res)
-Carries Out A Single Request From the Client
Void Destroy ()
-Cleans Up What Ever Resources Being Held
(Ex: Memory,File Handles)
Servlet Config Get Servlet Config()
-Returns As Servlet Config Object Which Contains Any Initialization
Parameters And Start up Configuration For This Servlet
String Get Servlet info()
-Returns A String Containing Information About the Servlet Such as it’s
Authors, Version & Copyright.
….Thank
You….

Servlet Life Cycle & Generic Servlet

  • 1.
    NADAR SARASWATHI COLLEGE OFARTS AND SCIENCE DEPARTMENTOF COMPUTERSCIENCE BY K.DIANA DEVI I M.SC(CS)
  • 2.
  • 3.
    Road Map Over viewof the life cycle Birth of a servlet Life of a servlet Death of a servlet
  • 4.
  • 5.
    Life of aservlet  Birth: Create and Intialize the Servlet  Important method: Init()  Life: Handle 0 Or more Client Request  Important method: Service()  Death: Destroy the Servlet  Important method: Destroy ()
  • 6.
  • 7.
    The init() MethoD The Init () Method Is Called When The Servlet Is First Request By A Browser Request  It Is Not Called Again For Each Request  Used For One Time Initialization
  • 8.
  • 9.
    Life of aservlet  The First Time A Servlet Is Called The Servlet Is Instantiated And It’s Init() Method is called  Only One Instance Of The Servlet Is Instantiated  This One Instance Handles All Browser Requests
  • 10.
    Service Method  EachTime The Servlet Receives A Request For A Servlet The Server Spawns A New Thread And Calls The Servlet Service () Method
  • 11.
  • 12.
    Death of aservlet  Before A Server Shuts Down It Will Call The Servlet’s Destroy () Method  You Can Handle Any Servlet Clean Up Here. Ex: Updating log Files Closing Database Connections Closing Any Socket Connections
  • 13.
  • 14.
    Void int(Servlet ConfigConfig) -Initializers The Servlet Void Service (Servlet Request req, Servlet Response res) -Carries Out A Single Request From the Client Void Destroy () -Cleans Up What Ever Resources Being Held (Ex: Memory,File Handles)
  • 15.
    Servlet Config GetServlet Config() -Returns As Servlet Config Object Which Contains Any Initialization Parameters And Start up Configuration For This Servlet String Get Servlet info() -Returns A String Containing Information About the Servlet Such as it’s Authors, Version & Copyright.
  • 16.