wood burning stoves 2.0*
The moose likes Struts and the fly likes Session Attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session Attributes" Watch "Session Attributes" New topic
Author

Session Attributes

Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Aug 11, 2012
Posts: 370
    
    1

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

Joined: Jan 10, 2002
Posts: 60780
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Attributes
 
Similar Threads
session scope quary
Session Object
How do we store objects in database table?
database with jsp
Custom Tag vs Java in JSP performance