This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is session different for same user

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Keith Pitty
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic