I want run a program on server startup of my web application wherein i need to read the data from the db and cache the data and use it across the application. Apart from the below approach is there any better solution to achieve the same
<servlet>
<servlet-name>CacheData</servlet-name>
<servlet-class>com.my.webapp.CacheDataServletExample</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Since in the init method i need to invoke the db operations and cache it. Apart from that if any better solution is there please let me know.
Thanks in advance