My question is: why is this preferable to something like a global db connection pool?
This is not true! All servlets must exchange connections in the pool!
Also, since I am thinking about implementing such a pool.
There are already ways (Spring IoC) to introduce container-managed federated connections.
. Is there a way to initialize a class before servlets (I use jetty btw)?
An IoC container can load every resource and servlet!
You can certify servlets in spring by registering Spring dispatcherServlet and xml containing mappings and servlets as bean definitions!
Use the following definitions if you only want to enter the connection and leave the rest of the servlet like this:
<bean name="simpleServletHandlerAdapter" class="org.springframework.web.servlet.handler.SimpleServletHandlerAdapter" /> <bean name="simpleServletPostProcessor" class="org.springframework.web.servlet.handler.SimpleServletPostProcessor" />
source share