aspose file tools*
The moose likes Servlets and the fly likes What is in the Session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What is in the Session?" Watch "What is in the Session?" New topic
Author

What is in the Session?

Anne Drew
Greenhorn

Joined: May 29, 2002
Posts: 6
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

Joined: Aug 13, 2001
Posts: 49
In the session are stored objects.
Each one has a "name"
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Check out the Servlet API for HttpSession -- you can call getAttributeNames() to get an enumeration of all the Objects in your session.


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
jawwad ahmed
Ranch Hand

Joined: Dec 01, 2001
Posts: 179
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

Joined: May 29, 2002
Posts: 6
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

Joined: Oct 17, 2001
Posts: 4313

size, as in how much memeory it is taking up?
Anne Drew
Greenhorn

Joined: May 29, 2002
Posts: 6
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

Joined: Dec 20, 2001
Posts: 3271
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


SCJP Tipline, etc.
Anne Drew
Greenhorn

Joined: May 29, 2002
Posts: 6
The size of each object in memory is what I am really looking for.
jawwad ahmed
Ranch Hand

Joined: Dec 01, 2001
Posts: 179
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

Joined: Dec 20, 2001
Posts: 3271
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is in the Session?
 
Similar Threads
Struts2: Different ways to use session
Question regarding Session Migration
lifecycle of session and request
Help Needed -- how do I store and retrieve a session variable?
Passing more than one object between jsp and servlet