• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Stupid question - Request scope vs Session scope

 
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
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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...
 
Marshal
Posts: 25682
69
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic