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

erasing bean from scope  RSS feed

 
Baba Bizlowsky
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

Is there a quick way to invalidate a bean? I understand that <jsp:setProperty> tag leaves everything as it were if I send in the null-values. But what if I want to erase the data from the bean (e.g. when the user is signing out)? Is invalidating the session the only way?

Thanks in advance. Cheers!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is HttpSession.removeAttribute.
You could also create your own clearProperties method which empties all of the properties in the bean.
If the bean implements HttpSessionBindingListener, you could have the method called automatically when the object is removed from session.

You could also wrap the clearProperties method with a plain setter or getter and call it from your jsp with a jsp:setProperty or jsp:getProperty tag.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!