Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Explain servlet lifecycle phases?

user-image
Question ajoutée par Utilisateur supprimé
Date de publication: 2014/01/20
Nisha A
par Nisha A

The Init() method- The init method is designed to be called only once

publicvoid init()throwsServletException{// Initialization code...}

 

The  service() method - The service() method is the main method to perform the actual task

publicvoid service(ServletRequest request,ServletResponse response)throwsServletException,IOException{}

 

The doGet() method-A GET request results from a normal request for a URL or from an HTML form that has no METHOD specified and it should be handled by doGet() method.

 

publicvoid doGet(HttpServletRequest request,HttpServletResponse response)throwsServletException,IOException{// Servlet code}

The doPost() method - A POST request results from an HTML form that specifically lists POST as the METHOD and it should be handled by doPost() method.

publicvoid doPost(HttpServletRequest request,HttpServletResponse response)throwsServletException,IOException{// Servlet code}

 

The destroy() method - The destroy() method is called only once at the end of the life cycle of a servlet.

publicvoid destroy(){// Finalization code...}

More Questions Like This