Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session attributes are thread safe

 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some doubt in pg 199 of HFSJ. There it says that "Client could open a new browser window.So the container can still use the same session for a client.....and thus session attributes are not thread safe."

But what i dont understand is that if the client opens up a new browser, then i guess its considered as a separate client by the server and thus they are two separate requests by 2 different clients.
Please explain me the scenario

( As far as i know every instance of the browser is a separate client for the server )
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Well, these kind of doubt clear when you did small application only...

you please do some application based on session

hint:

if you open application from IE and also you can open same application from another window(IE) right?

in this case the browser uses same session id...thats why session attributes are not thread safe


you try to implement below one atleast you get some points

servlet code:
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maan Shenoy:
( As far as i know every instance of the browser is a separate client for the server )

Nope.

This may have changed in the most recent browser versions, but in the past if the second browser window was created from the first (like a link opening a second window or the user hitting Ctrl+N) then the second will share the same session.

Even with only one window you could run into problems if a user submits the same form multiple times with a quick finger.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot SeethaaRaman and Marc.
Marc , can you please explicate exactly what happens when the user clicks the submit button multiple times and how are session variables not thread safe........
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic