This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When does a Session Attribute loose Its Value  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1775
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I assign a session attribute a value when does this session attribute loose its value? I have a strange thing happening. When the user chooses a selection fro a list a value is assigned to a session attribute. At some point in time when the app tries to session.getattribute it returns null. If the session attribute is set then the user accesses another web site then uses the back button to the page where the attibute was set should the value still be as it was?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The session scoped variable will retain the same value until you explicitly change it or the session terminates.
 
Sherlock Yao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the session is time-out when the user is visiting other sites, so you get the NULL value
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of one case in which a session could lose one reference but not others.

If the object refered to is NOT serializable and the servlet container tries to serialize the session, the reference will get lost. In that case an exception is generated and you should see it in the logs.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!