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?
Actually <load-on-startup>1</load-on-startup> is use just load your servlet to load into container.
The basic of why this need is when your servlet complex and it takes time to load on container then you just load that servlet at start of your server.
basically the servlet get load into container when first user request for that servlet. so, if your servlet takes time to load when user request at that time you just load servlet.
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.