If you want some code to run at startup, you could either put it in a servlet and specify the load-on-startup flag, or you could write an MBean which will get initialised at system startup.
I'm not sure how you would run code at shutdown though...
Well, it depends upon the purpose of startup tasks. If the startup task needs to use the resources started by the server, then the ServletContextInitializer is a right place. Whereas, If the startup task needs just setting up some data, testing some external connections (out side the J2EE container), then these can go as part of run.sh
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, the permaculture playing cards