Implement a ServletContextListener
, do the desired loading task during contextInitialized()
and store the result in the application scope by ServletContext#setAttribute()
. It will be invoked during server's startup and the application scope is accessible inside regular servlets as well.
Basic example:
public class Config implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
List<Foo> foos = fooDAO().list();
event.getServletContext().setAttribute("foos", foos);
}
}
Map it in web.xml
the usual way:
<listener>
<listener-class>mypackage.Config</listener-class>
</listener>
Here's how to access it in regular servlets:
protected void doSomething(request, response) {
List<Foo> foos = (List<Foo>) getServletContext().getAttribute("foos");
}
And here's how you can access it in JSPs:
<c:forEach items="${foos}" var="foo">
${foo.someProperty}<br>
</c:forEach>
That said, I really don't see how that is related to "servlet pool". This term makes no sense.
Hope this helps.