Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The servlet life cycle ?

Status
Not open for further replies.

outis

Programmer
Jun 20, 2001
21
MX
hi! I need to know if a servlet that is active, remains charged until the servlet engine is shutdown by de administrator(manually), or if there is any other situation that makes the servlet inactive. Im working with WebSphere Application Server

I like to keep my servlet active allways.

thanks for your time
 
According to the Servlet Specifications a Servlet that is created and initialized can service 0 or more requests before it is taken out of service and destroyed. Therefore a Servlet Engine could create and initialize a Servlet, allow it to handle one request, and then destroy it. Obivously this is not what they do in practice but it is allowable. If your Servlet must keep state between requests then it is recommended that some form of persistant storage (such as files or a DB) be used and that this functionality be taken into account in the init and destroy lifecycle methods. Wushutwist
 
There is a choice in WebSphere to have servlets load on startup or load on reference. I don't know anything more than that sorry - I am learning the app myself, but if you find out how to do it please let me know.
 
To load a Servlet on startup you need to add the following XML tag to the Deployment Descriptor within the Servlet Tag:
Code:
<web-app>
   <servlet>
     .....
     <load-on-startup>1</load-on-startup>
   </servlet>
</web-app>
Notes:
The number specified in the tag also controls the order of startup, meaning the larger the number the sooner the startup. 0 specifies the startup order is not important.

Lastly, this is not an ability restricted to WebSphere any container that implements Servlet 2.2 or greater needs to support this. Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top