Redian新闻
>
One more servlet Q: Http Session
avatar
One more servlet Q: Http Session# Java - 爪哇娇娃
r*s
1
I got some weird problem with session handling. Maybe I
misunderstand something about session. Don't the objects
stored in the session belong to the current session only?
Why can other sessions get the objects?
Here, I put a service reference to session:
session.setAttribute(SERVICENAME, ref);
Should I add the session id too to distinguish the key?
session.setAttribute(SERVICENAME+session.getId(), ref);
Could Qing DX give give some light on it?
Thanks!
avatar
Q*g
2
I am not sure about this.
My understanding is that a session is unique for each conversation between
the browser and the server.
I guess in your case you are actually in one session. I mean, maybe a child
browser window(eg. pop windows) is in the same session as the parent. But if
you start a new browser window manually, you should be in different sessions.

【在 r*****s 的大作中提到】
: I got some weird problem with session handling. Maybe I
: misunderstand something about session. Don't the objects
: stored in the session belong to the current session only?
: Why can other sessions get the objects?
: Here, I put a service reference to session:
: session.setAttribute(SERVICENAME, ref);
: Should I add the session id too to distinguish the key?
: session.setAttribute(SERVICENAME+session.getId(), ref);
: Could Qing DX give give some light on it?
: Thanks!

avatar
r*s
3
that's what I understand ... the situation is, even different users
with different browsers can get the reference object from the session.
Isn't it weird? BTW, my web server is Tomcat. Is there any bug with it
for the session implementation?

【在 Q**g 的大作中提到】
: I am not sure about this.
: My understanding is that a session is unique for each conversation between
: the browser and the server.
: I guess in your case you are actually in one session. I mean, maybe a child
: browser window(eg. pop windows) is in the same session as the parent. But if
: you start a new browser window manually, you should be in different sessions.

avatar
w*t
4
I don't think so. try to print out session id , I believe you'll see they are
in same session.

child
if
sessions.

【在 r*****s 的大作中提到】
: that's what I understand ... the situation is, even different users
: with different browsers can get the reference object from the session.
: Isn't it weird? BTW, my web server is Tomcat. Is there any bug with it
: for the session implementation?

avatar
m*t
5

session id is typically sent back through either a cookie or part of
the url. should be fairly easy to see.

【在 w******t 的大作中提到】
: I don't think so. try to print out session id , I believe you'll see they are
: in same session.
:
: child
: if
: sessions.

avatar
r*s
6
thanks. i did print out the session ids. they are different for sure.

【在 w******t 的大作中提到】
: I don't think so. try to print out session id , I believe you'll see they are
: in same session.
:
: child
: if
: sessions.

avatar
A*o
7
Since everything you test looks right, let's think the other way:
maybe you assign these session the same reference?

【在 r*****s 的大作中提到】
: thanks. i did print out the session ids. they are different for sure.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。