Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is in the Session?

 
Anne Drew
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to determine what I have in session at any given time. To that effect I am trying to write a jsp that will get the objects in session and then list them. This Jsp is independant and would read the current browser session.
Also I would like to know the size of these objects.
Is this possible
Please Help
 
Ivan Tamayo
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the session are stored objects.
Each one has a "name"
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the Servlet API for HttpSession -- you can call getAttributeNames() to get an enumeration of all the Objects in your session.
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session means period like in class u have period and at parrticular period u study.That material u get from that period.
In real world like shopping card application u put information like what the current user have buied the things.
U can put id of user.
U can also put session bean object reference.
its all depends upon your design and what u think.
Jawwad Ahmed
SCJP
SCWCD
jawwad_java@yahoo.com
 
Anne Drew
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have got my list of attributes from the session.
How can I determine the size of the session object? Can I also determine the size of each object in the session?
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
size, as in how much memeory it is taking up?
 
Anne Drew
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if possible but maybe more like how many bits. The reading I have been doing since my post makes me think that I could serialize the session object and place in a byte[], then get how many bytes in takes up.
I can't make sense of the IO. Is this even possible?
Thanks
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to serialize all of the objects from the session and then check the sizes of each, but the size of an object after serialization is not necessarily the same as the size of the object in memory. It really depends upon what you're looking for. Are you looking for the size of the objects after serialization, or do you want the size of each object in memory?
Corey
 
Anne Drew
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The size of each object in memory is what I am really looking for.
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Session object is unlimited in memory size theoratically but it depends upon your server memory.
For more info see jguru servlet faq.
Jawwad Ahmed
SCJP
SCWCD
jawwad_java@yahoo.com
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anne Drew:
The size of each object in memory is what I am really looking for.

Unfortunately, I don't think there is a way to know how large each object is in memory. Perhaps someone knows of a way, but I've been involved in a number of discussions about this and no one has ever been able to come up with a good solution.
Corey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic