“Servlet” (server-side) initialization code in GWT

You can add like mentioned in a comment a ServletContextListener.

public class ServerConfig implements ServletContextListener {

    public void contextInitialized(ServletContextEvent event) {
    // Do stuff on startup.
    }

    public void contextDestroyed(ServletContextEvent event) {
    // Do stuff on shutdown.
    }
}

Now put the new class on the server side, you also ave to register the Listener in your web.xml file :

<listener>
<listener-class>path.to.class.ServerConfig</listener-class> 
</listener>

Leave a Comment