Life Cycle of Servlet

Life Cycle of Servlet

Life Cycle of Servlet
Ganesh
Monday 29 May 2017
Life Cycle of Servlet-


1. init() - เคฏเคน servlet เค•ो initialize เค•เคฐเคจे เค•े เคฒिเค เคฌเคจाเคฏा เค—เคฏा เคนै เคคเคฅा เค‡เคธ method เค•ो เค•ेเคตเคฒ เคเค• เคฌाเคฐ call เค•िเคฏा เคœा เคธเค•เคคा เคนै, เค…เคฐ्เคฅाเคค เค•ि เคนเคฐ user request เคชเคฐ init() method เค•ो call เคจเคนी เคนोเคคा เคนै।
          init() method เคตเคน data create เค•เคฐเคคा เคนै เคœो เค•ि servlet เค•ी เคชूเคฐी lifecycle เคฎें use เค•िเคฏा เคœाเคฏेเค—ा।
Example- public void init() throws servlet exception{};

2. Service()- เคฏเคน main method เคนै, เคœो เค•ि task เค•ो complete เค•เคฐเคคा เคนै, web server , service() method เค•ो call เค•เคฐเคคा เคนै เค‰เคธเค•े เคฌाเคฆ service() method เคฆ्เคตाเคฐा client เค•ी request handle เค•ी เคœाเคคी เคนै เคคเคฅा service()method เคนी client เค•ो response send เค•เคฐเคคा เคนै।
          Server เค•े เคชाเคธ servlet เค•ी request เค†เคคे เคนी server เคเค• เคจเคˆ thread generate เค•เคฐเคคा เคนै เคคเคฅा service()method เค•ो call เค•เคฐเคคा เคนै, เค‰เคธเค•े เคฌाเคฆ service()method http request เค•े เคช्เคฐเค•ाเคฐ เค•ो check เค•เคฐ เค•े เค‰เคธเค•े เค…เคจुเคธाเคฐ function เค•ो call เค•เคฐเคคा เคนै।

Example- http request เคฏเคฆि GET() เค•ी เค—เคฏी เคนै เคคो service()method Do GET() Function เค•ो เค•เคฐेเค—ा।

3. Destroy() - เค‡เคธ method เค•ो servlet เค•ी life cycle เค•े end เคฎें call เค•िเคฏा เคœाเคคा เคนै।
Destroy() method call เค•เคฐเคจे เคชเคฐ servlet เค•ो database connection เค•ो stop เค•เคฐเคจे, background thread เค•ो halt เค•เคฐเคจे เคคเคฅा เค…เคจ्เคฏ process เค•เคฐเคจे เค•ा chance เคฆिเคฏा เคœाเคคा เคนै।

Example- public void destroy();
Destroy() method เค•े เคฌाเคฆ servlet เค•े object garbage collection เค•े เคฒिเค mark เค•เคฐ เคฆिเค เคœाเคคे เคนैं।
Open Comments
Close comment

1 comment