How to maintain user sessions in DropWizard?

人盡茶涼 提交于 2019-11-30 19:57:56

With dropwizard>0.7

environment.jersey().register(HttpSessionProvider.class);
environment.servlets().setSessionHandler(new SessionHandler());

And then use @Session annotation in your resource classes.

Madhan Dennis

DropWizard does not support sessions out of the box and based on posts by the author in google groups, they aren't planning on supporting it in the future either.

The only way currently would be for you to implement org.eclipse.jetty.server.session.SessionHandler yourself or look for something that already exists and then call environment.setSessionHandler(...)

And in case you need this info, DW 0.6.2 uses Jetty 8.1.10

You can also checkout http://cosmo-opticon.net/blog/2013/1/23/session-based-security-in-dropwizard and see if you can reuse some of that.

REST is by definition stateless so no sessions should be used at all. The same URI should always return the same results regardless of the session state.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!