A JavaEE web application does not have a “core class” in the same sense as a desktop application; Of course, execution should begin with the main method somewhere, but it will be controlled by a web container (Tomcat in your case) and beyond your reach.
Instead, you can create a servlet that preloads the data that you need in the application context using its init method (provided that the data is the same for all clients, and ideally it will not be changed by them). In addition, in the servlet configuration, you indicate that the servlet should be loaded at startup, and thus you will ensure that the data will be loaded once at the beginning of the application and that all clients will be able to access it from the application context.
EDIT:
In later versions of the Servlet specification (2.3+), the preferred way is to use contextual listeners, see this for more details.
source share