• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Attributes

 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I'm trying to store an ArrayList object in HttpSession, serializing the objects it contains. But, I'm unable to find that attribute in session, next time I retrieve it.
This doesn't work even if I stored a plain String object in session.

I was however able to store and retrieve the same objects from ServletContext.

Why could this be happening.

thanks
Allen
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not clear with your question. you put object into session with some key(attribute name) and get back the object using that key...
 
R. Jain
Ranch Hand
Posts: 375
1
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allen Bandela wrote:Hello

I'm trying to store an ArrayList object in HttpSession, serializing the objects it contains. But, I'm unable to find that attribute in session, next time I retrieve it.
This doesn't work even if I stored a plain String object in session.

I was however able to store and retrieve the same objects from ServletContext.

Why could this be happening.

thanks
Allen


I think you need: - request.getSession(false) to get the existing Session. And then you can fetch the attribute set.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you put the objects in the session (and what's up with the serialization? :confused: ) and how are you retrieving them? Keeping us guessing isn't going to get you much concrete help.
 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know I'm not removing it from session anywhere else in the application.
The attribute is being found in ServletContext but not in Session.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you aren't removing that attribute from the session, but the next time you look at the session it isn't there, then a reasonable conclusion would be that there are two different sessions involved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic