But the first program only gets started.How could i start two programs when the server starts.
What you mean by "starting programs" ? "<load-on-startup>" make the server loads the servlet class at the server startup rather than waiting till the first request. If you mean the same, how you verifed that two servlets are not loaded?
Use a HttpContextListner instead, its the first event that will take place, and place your configuration in the contextInitialized() method. the events that you want to occur when closing the app, can be put in the contexDestroyed() method.