There is no main()
method, because the components are managed and the container invokes other methods - like the init()
on servlets and filters. The container itself is started through a main method, but even that's hidden from you.
For per-application and initialization you can use a ServletContextListener
You have to map it in web.xml
using ...
. In contextInitialized(..)
and contextDestroyed(..)
you can do initialization and cleanup respectively.