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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write startup code 1

Status
Not open for further replies.

phatening

Programmer
Aug 8, 2005
18
US
Hi fellow programmers,

Does anyone know how to write startup code(code that is ran only when the web app is started or restarted) for a web application thats being written with JSP and Java servlets?

I'm trying to write code that accesses the database once everytime the web application is started/restarted to delete expired records.

I appreciate any help. Thanks.
 
The HttpServlet has an init() method which is called by the servlet container when the servlet is placed into service (this is inherited from GenericServlet). You can override this method in your servlet class to achieve your aims.

Note that there is a matching destroy() method which is called by the servlet container when the servlet is taken out of service.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top