Register now or log in to join your professional community.
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...}