Skip to content

Instantly share code, notes, and snippets.

@xkr47
Created October 8, 2014 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkr47/0e58f8e0ab5f9eb90e63 to your computer and use it in GitHub Desktop.
Save xkr47/0e58f8e0ab5f9eb90e63 to your computer and use it in GitHub Desktop.
Disable persistent sessions in Tomcat embedded (which includes wicket sessions) (works at least with tomcat 7.0.54)
Tomcat tomcat = new Tomcat() {
@Override
public Host getHost() {
if (host == null) {
host = new StandardHost() {
@Override
public void addChild(final Container child) {
if (child instanceof StandardContext) {
setupContextWithNonpersistentSessionManager(child);
}
super.addChild(child);
}
private void setupContextWithNonpersistentSessionManager(final Container child) {
StandardManager mgr = new StandardManager();
mgr.setPathname(null);
child.setManager(mgr);
}
};
host.setName(hostname);
getEngine().addChild(host);
}
return host;
}
};
tomcat.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment