Downloading data at application startup is a common task; you will find several examples on the Internet. As other answers say, you should implement a ServletContextListener (which is not specific to Struts2) ... you can read a great example here .
It is important to understand the concept of action:
In the Struts2 MVC (Model View Controller) Framework, Action is the Controller (and part of the Model ).
Action is called by Request , coming from Client (and one action is created for each request, therefore they are thread safe).
This means that you need a client, which usually means a guy in front of a computer, clicking on a browser ... then a client call is not the right trigger for performing an automated server operation on shared objects.
Of course, you could implement some form of lazy-initialitazion (for example, using a custom Interceptor) so that the first user can configure something in the application area, and other users can get an already filled object, but this is not the best way to do this ( you have to handle concurrency in initialization, and you will have one user, the first one, waiting for operations that the server could do at night at startup ...).
source share