my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Session -Browser window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Session -Browser window" Watch "Session -Browser window" New topic
Author

Session -Browser window

amarkirt saroay
Ranch Hand

Joined: Mar 16, 2008
Posts: 167

Please validate my understanding:


1)Everytime a new Session gets created when a new browser window is opened on the same machine.

2)Session id /session remains same if user does: File->New Window from the IE browser window?

SCJP-75%
SCWCD-82%
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
1)Everytime a new Session gets created when a new browser window is opened on the same machine.


Yes,Everytime new session is created if that web developer is not done some coding to avoid that.
(e.g. Just Login to javarach in IE close IE from cross at right upper side and again open new IE browser see you are still login that means session is get maintained same for google's gmail)

Session id /session remains same if user does: File->New Window from the IE browser window?


yes it is same.


Thanks,
Shailesh
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi, Amarkirt. Everytime new session's will gets created, only when different new browser windows are opened on the same machine. New session's will not gets created, if we open with same type of windows.

The process is, if we open a gmail or yahoo or any application that use sessions internally, will creates session object, when a request comes, and encapsulated it into cookie object and will add to the response header and will sent to the client(browser). Now the browser is having cookie(inside it session id present). And everytime the browser will communicate to that site with this session id.

Suppose if we open gmail in two new windows of same type, like two firefox or windows IE, the gmail application will not create two different session objects. If a request made to gmail through firefox, the gmail application create session object and will sent to the firefox in the form of cookie. If we open the same gmail in different firefox window, the firefox uses the first cookie object. Already the session id sent to the firefox in the form of cookie. The two different firefox windows communicates to the gmail with same session id. The firefox uses that cookie everytime it needed to communicate, it is same incase of IE.

If we open the gmail one with firefox and another in IE, then the gmail application will create two different session objects, one for firefox and another for IE.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Hey Chinmaya , Great Explanation!!!
Keep up the good work!

When i opened Gmail and yahoo in the same browswer window (different tab) it was signed in.
Howevere when i opened a fresh IE window, I was not signed in.
That means Gmail and Yahoo are maintaining the session based on the browser window

However in case of Java ranch , I was logged in both the cases ( when i opened it in the same window (new tab) and even in a complete new IE window).
Does that mean it maintains its session based on the IP address or something and not on the browser window
And that different applications maintain session in different ways..

Just wanted to know if I am thinking on the right track...


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi, Nabila. Thankyou. JavaRanch follows different strategy, rather than providing unique session id. I think it will not made session's depending on IP address. Incase of private network, we have local IP addresses. The server will not send packets to local IP address system directly. It will first sent to the router(router maintain's a table containing the local IP address details), it is the job of router to send the packets to the system which made a request to server. To the server, IP address of the system is the IP address of the router. I think JavaRanch will not follow this strategy. I think it follows unique hardware installation key, every system will have unique key(I am not sure about this).
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
That makes sense!!!

Thanks for the explanation.

Take care!
 
 
subject: Session -Browser window
 
Similar Threads
Sessions in JSP page
Session Management
About Sessions
Servlet session
Can a servlet open a new browser window?