| Author |
Session conflict with servers on the same IP and different ports
|
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 666
|
|
When I run servlet on localhost HttpSession.getId() returns id = A
Then I run servlet on localhost:8080 I got a new session B
Then I go back to run servlet on localhost I got a new session C!
Then I go back to run servlet on localhost:8080 I got a new session D!
The sessions seem to step on each other. Why?
|
BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design
Crazy Bikes created by m-Power
|
 |
Chinmaya Chowdary
Ranch Hand
Joined: Apr 21, 2008
Posts: 432
|
|
Hi, Bruce.
Have you disabled cookies on the browser side?
|
 |
Kamal Mettananda
Ranch Hand
Joined: Oct 25, 2005
Posts: 50
|
|
Hi,
Are you running your web server in two ports (80 and 8080) ? It seems you are calling urls on two ports.
Can you explain the way you are using these two ports?
Cheers,
Kamal
|
Regards,Kamal
SCJP 1.4 (98%)
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
Those are all different domains as far as cookies are concerned. And as cookies goes, so goes the session.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 666
|
|
I have 1 Tomcat on port 80 and another on port 8080.
if those are all different domains as far as cookies are concerned, why session on domain bumps session on another domain?
|
 |
Chinmaya Chowdary
Ranch Hand
Joined: Apr 21, 2008
Posts: 432
|
|
Hi, Bruce.
if those are all different domains as far as cookies are concerned, why session on domain bumps session on another domain?
I am guessing, I have not tried this.
Session id's are created randomly. Container creates one 'session id' for one domain and another 'session id' for another domain.
|
 |
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 666
|
|
ssion id's are created randomly. Container creates one 'session id' for one domain and another 'session id' for another domain.
That's what I thought. The confusion thing is that
When I run servlet on localhost I got a session A
Then I run servlet on localhost:8080 I got a new session B
Then I go back to run servlet on localhost I got a new session C! (session A disappeared!)
Then I go back to run servlet on localhost:8080 I got a new session D! session B disappeared!)
Basically when I go to one of the URLs the session Id in another Url is invalidated.
|
 |
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 666
|
|
I am using Tomcat in both ports 80 and 8080.
I am not sure if this happens in other server too.
|
 |
 |
|
|
subject: Session conflict with servers on the same IP and different ports
|
|
|