Java: reload servlet configuration
How to reload the configuration of a Java servlet
To reload servlet configurations, you simply need to implement the ServletContextListener interface.
Example:
Example:
package utils;
import javax.servlet.*;
public class MeuListener implements ServletContextListener {
public MeuListener() {}
public void contextInitialized(ServletContextEvent event) {
ServletContext sc = event.getServletContext();
sc.setAttribute("seu atributo", "seu valor");
...
}
public void contextDestroyed(ServletContextEvent servletcontextevent) {}
}
Thus, we can, for example, reload configurations without needing to stop the application.