This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSP and the fly likes erasing bean from scope Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "erasing bean from scope" Watch "erasing bean from scope" New topic
Author

erasing bean from scope

Baba Bizlowsky
Ranch Hand

Joined: Dec 15, 2003
Posts: 39
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: erasing bean from scope
 
Similar Threads
servlet , bean , jsp Communication
Injection problem - not quite sure if this is something i should be using injection for
How to refresg a bean in Session
Wrapp entity bean
Setting Bean property