Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

What is in the Session?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the session are stored objects.
Each one has a "name"
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie. tiny ad:
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
reply
    Bookmark Topic Watch Topic
  • New Topic