开发者

Handling Session ID with Spring

I'm trying to build a Spring server for GWT (you can think of it as of Javascript AJAX client). But I can't decide on one point of architecture. How should session be created and used?

The obvious easiest way - is to use HTTP sessions (cookies and stuff). Looks fine, but I think that sending session ID separate from the headers would be better (SOAP style).

So, what is better: getMyPetsName(String sessionID, int petID) or getMyPetsName(int petID) + session ID through HTTP header (cookies or something).

Another question is, if I use the first way (which I like more) - how do I handle session in Spring? I'm rea开发者_开发知识库lly newbie in Spring, and googling did not help. What I mean is:

String getMyPetsName(String sessionID, int petID) {
    Session s = someWayToGetItById(sessionID);
}

Thanks in advance.


If you can choose it I would opt for always sending the session id.

It will make things a lot easier, also when a user opens multiple tabs in the same session.

If you are not using Spring MVC I do not think Spring will put much constraints/assumptions on how you handle the session. There are many caches, like ehcache, which can be set up using spring and store your sessions. The better caches also allow the sessions to be distributed over machines and stored persistently without impacting on the code base.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜