Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stupid question - Request scope vs Session scope

 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All

Stupid question. Am I right in assuming that there is little difference in the amount of data transfered over the network for objects stored in request scope, accessed in a JSP, vs objects stored in Session scope accessed the same way?

The objects are just stored in the same way right? The reference client side to a request attribute and a session attribute is the same?

The reason for asking is that someone at work today stated they were moving a map of objects to session scope instead of accessing them through request attributes to reduce network traffic - am I missing something that I should know here?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rick Beaver:
Am I right in assuming that there is little difference in the amount of data transfered over the network for objects stored in request scope, accessed in a JSP, vs objects stored in Session scope accessed the same way?


There is no difference because there is no data transferred over the network in either case. And zero is pertty close to zero. The variable scopes are completely server-side mechanisms.


The objects are just stored in the same way right? The reference client side to a request attribute and a session attribute is the same?


There is no client-side reference to either.


The reason for asking is that someone at work today stated they were moving a map of objects to session scope instead of accessing them through request attributes to reduce network traffic - am I missing something that I should know here?


He's confused and making a major blunder if he's moving data to session scope for any reason other than making it available across multiple requests. He's probably just creating a memory leak.
[ April 13, 2006: Message edited by: Bear Bibeault ]
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear, I didn't want to correct the chap because I started to doubt myself when he said that...
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually it's possible that if you put an object into session scope, the container might serialize it to a database (if you configured persistent sessions into the container). And your database might well be on a different machine. So that would actually INCREASE the network traffic, rather than decreasing it.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Clapham:
Actually it's possible that if you put an object into session scope, the container might serialize it to a database (if you configured persistent sessions into the container). And your database might well be on a different machine. So that would actually INCREASE the network traffic, rather than decreasing it.


In addition, if you're clustering your app servers with session replication.
Every change to the session object will result in it being serialized and synced with the sessions in the other nodes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic