• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where are data in HTTPSession stored?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTTPSession is a high level interface built on top of cookie and url-rewriting, that means there is only a session id stored in client, the relative big data are stored in server.
I'm not talking about how to save data with HTTPSession interface. I'm just wondering where are the data actually stored in server? In the memory or somewhere?
How can I change the place to store, e.g. I want to save them into a in-memory database, how could I do that?
Btw, if it's not in a database, is there any concurrency problem when many client work on a same session data at the same time?

thanks
 
Saloon Keeper
Posts: 7585
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it's stored in memory. Some servlet containers write sessions to disk during a restart, but not during normal operation.

Why would you as the application developer care about where the sessions are stored, or want to interfere with a mechanism that is working fine?

Indeed, the content of sessions is not thread-safe unless you take precautions to make it so. That's generally not a big deal, because sessions are normally restricted to single users. So the "many client" scenarios you describe should not happen.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is my understanding that Servlet containers are allowed to write sessions to disk any time they want to - presumably this would come up when free memory is getting low. This is why your objects having references in a session need to be Serializable.

Bill
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there any concurrency problem when many client work on a same session data at the same time?

For every client a new session is created . you do not have worry about that and i think there is no way a client can interact with another client's session . (may be possible if you know the session id). Why are yu trying to change the storage space for session data?
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you elaborate about this "many clients, same session" scenario? As I said, each client gets their own session. Sessions are not appropriate for storing data for many clients.
 
Sunil Sunny
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Can you elaborate about this "many clients, same session" scenario? As I said, each client gets their own session. Sessions are not appropriate for storing data for many clients.



This is true "each client gets their own session." i know that . Who said many clients and same session?. The misunderstanding has occured because I just copied the first line from the topic starter's post.
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Who said many clients and same session?


You did, by asking about it. If that was a quote you should make that obvious by using quote tags. Otherwise it looks like regular content.
 
Sunil Sunny
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok actually i was in a hurry at that time . I will care for it the next time .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic