Enabling filtering for Tomcat by extending AbstractHttpSessionApplicationInitializer

In the previous step, Servlet Filter needs to be enabled on every request to the Servlet Container (Tomcat). The following snippet shows the code involved:

    public class Initializer 
extends AbstractHttpSessionApplicationInitializer {
public Initializer() {
super(ApplicationConfiguration.class);
}
}

That's all the configuration you would need. The great thing with Spring Session is the fact that your application code talking to HTTPSession does not change! You can continue using the HttpSession interface, but in the background, Spring Session ensures that the session data is stored to an external data store - Redis in this example:

    req.getSession().setAttribute(name, value);

Spring Session provides simple options to connect to an external session store. Backing up your session on an external session store ensures that your user can fail over even when one of your application instances goes down.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset