The Life Cycle Of a Servit Java Help

The Life Cycle Of a Servit 
. Three methods are central to the life cycle of a servlet into service Land destroy( ). They are implemented by every servlct and arc invoked at specific limes by the server . Consider rrcxt’ a typical user sccnano, to understand when these methods .irc called. First, assume that a user enters a Uniform Resource Locutor (URL) to .l Web browser. The browser then generales ail HTTP n:qllest for this URL and sends it to the appropriate server.

Second, this HTT1′ request is received by the Web server. The ~er’er maps this request to a particular scrvlct. The servlet is dynamically retrieved and loaded inlo (he address space of the server.

Third, the server invokes the inil( ) method of the scrvlet. This method is invoked only when the servlct is first loaded into mel1lory. You will see that initialization . parameters can bepassed to the scrvlet so that it may configure itself. ‘Fourth, the server invokes the servlct’s scrviccl ) method, which is called to process the HITP request. You will see that the scrvlet can read data that has been provided in’ the HITI’ request, and may also formulate an H’Fl’P responsc for the client. The scrvlet remains in the server’s address space and is available to process any other HTTP requests received from clients. The scrvicct ) method is called for each HITP request.
Finally, the server may decide to unload the servlet from its jnc memory, The algorithms by which this dcl~mini.lion is made are specific to each server. The server calls the destroy ) method relinquish any  such as file handles that me allocated for the scrvlct. Important datu may be saved to a persistent slow. The memory allocated for the servlct LIl1.Jits objects can then be tjilrbaee·collectcd,

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 18, 2014 in Servlets

Share the Story

About the Author

Back to Top