2012-08-28 33 views
1

我正在寻找用于创建jsessionids的默认代码库。它可能因实例而异,但我似乎无法在网上找到它,只是解释如何更改/设置它。寻找代码来生成jsessionid

谢谢

回答

0

JSESSIONID cookie是在会话创建时创建/发送的。会话在您的代码首次调用request.getSession()或request.getSession(true)时创建。如果你只想获得会话,但不创建它,如果它不存在,请使用request.getSession(false) - 这将返回一个会话或null。在这种情况下,不会创建新会话,并且不会发送JSESSIONID cookie。 (这也意味着会话不一定第一个请求创建......你和你的代码是当创建会话控制)

会议是每个方面:

SRV.7.3 Session Scope 

HttpSession objects must be scoped at the application (or servlet context) level. The underlying mechanism, such as the cookie used to establish the session, can be the same for different contexts, but the object referenced, including the attributes in that object, must never be shared between contexts by the container. 
+0

明白了;但是这是对发生的事情的解释。我正在寻找的是如何生成cookie值。例如,这里是对asp.net的解释http://www.codeproject.com/Articles/16822/The-Anatomy-of-Forms-Authentication – hahahahey

+1

它看起来像我在AbstractSessionIdManager中找到我正在寻找的代码。这会生成成为JSESSIONID的cookie值的字符串。 – hahahahey