The J2EE Specification doesn't define Application Server startup lifecycle events, however there are a couple standard ways this is done without restorting to vendor specific apis...
1. Use a
ServletContextListener and implement your startup code in the contextInitialized() method.
2. Use a "startup servlet", which is basically just a
Servlet with its load-on-startup value set to 0. Implement your startup code in the servlet's init() method.
The "better" solution of the two is #1, however it requires a Servlet 2.3 or higher container and, since load order isn't defined in the spec,
you should check to make sure your container initializes listeners before servlets.
* WebLogic and Oracle Application Servers in the past initialized Servlets before Listeners. This behavior might have changed with the latest releases.