aspose file tools*
The moose likes Servlets and the fly likes Session conflict with servers on the same IP and different ports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session conflict with servers on the same IP and different ports" Watch "Session conflict with servers on the same IP and different ports" New topic
Author

Session conflict with servers on the same IP and different ports

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 667
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: 51

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


Kamal Mettananda - SCJP 1.4 (98%)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61419
    
  67

Those are all different domains as far as cookies are concerned. And as cookies goes, so goes the session.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 667
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: 667
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: 667
I am using Tomcat in both ports 80 and 8080.
I am not sure if this happens in other server too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session conflict with servers on the same IP and different ports