aspose file tools*
The moose likes Servlets and the fly likes is session different for same user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "is session different for same user" Watch "is session different for same user" New topic
Author

is session different for same user

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi
session is created when ever a new request is received by the server and maintained till time expires or that request has been closed.

take for example if i am opening n browser for same website URL did that mean n sessions are created and maintained by the user.

since new sessions are created when there is no session object associated with the request, the consequent request from the same user with n no of browser may create n no of sessions

Am i right, correct if i am wrong.
Scheepers de Bruin
Ranch Hand

Joined: Jul 19, 2005
Posts: 99
You are correct in your statement that n browsers = n sessions, however the session is not closed when the request is, but rather when it times out, or is manually invalidated.

Remember a web-app interacts with a user via a series or requests and responses, and the session would be utterly useless if it expired after each response. There would be no state management!


We're doomed!!<br />Yay!!!<br />No that's bad Girr!!<br />Yay!!!
Keith Pitty
Ranch Hand

Joined: Sep 22, 2005
Posts: 32
Actually, it is possible to have more than one browser using the same HttpSession object. It depends on the browser and how it is opened.
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi kieth
can i say on opening the browser for the same website by right clicking the mouse and giving open in new window wont create a new session object the request will proceed with the same session object.../

But when the user is issuing the link by opening a new browser i hope the new session will be created

correct me if i was wrong.
Keith Pitty
Ranch Hand

Joined: Sep 22, 2005
Posts: 32
It also depends on the browser. Unfortunately I don't have the details at hand but I do know that there are differences in the way different browsers (e.g. IE, Firefox, Safari, Opera) behave with respect to whether or not new HttpSession objects are created when new browser windows are opened.

Perhaps someone else can shed some light on how the different browsers behave.
Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
From my experience when a request originates from an already existing session in a browser. The session continues, no new session is instatiated as long as the origination of the request is from the same window.

So when yu open a new browser window by right-clicking and opening a new window the session is maintained.

I have tried this with internet explorer and with Mizilla Firefox.


SCJP 1.4, SCWCD 1.4
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler et al, Refactoring: Improving the Design of Existing Code, 1999
Scheepers de Bruin
Ranch Hand

Joined: Jul 19, 2005
Posts: 99
Correct on the opening of a browser from the same window.
I misread the "same" part.
[ September 28, 2005: Message edited by: Scheepers de Bruin ]
Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
I feel that there is no need to know, how different browsers behave with respect to sessions. Anyways, as developers we need to write a generic code and container developers should also write a generic code.

Even the servlet specification states that, NEVER assume 1 browser window = 1 session.

They say that Cookies and SSL certificates are all part of the browser process and NOT part of a SINGLE BROWSER.

Specification states that we(developers) should always assume that request from multiple windows can still be part of same session.


Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi
is the session created Automatically i read some where the sessions are created automatically,

but in other notes i found that we need to give the following lines to make the session available for the request

HttpSession session = request.getSession(true);

which one is right....
any one
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is session different for same user