This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
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
 
wood burning stoves
 
subject: erasing bean from scope