| Author |
Stupid question - Request scope vs Session scope
|
Rick Beaver
Ranch Hand
Joined: Dec 14, 2004
Posts: 464
|
|
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
|
ph34r my 133t j4v4 h4><0r1ng sk177z
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56179
|
|
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 ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Rick Beaver
Ranch Hand
Joined: Dec 14, 2004
Posts: 464
|
|
|
Thanks Bear, I didn't want to correct the chap because I started to doubt myself when he said that...
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: Stupid question - Request scope vs Session scope
|
|
|