aspose file tools*
The moose likes Servlets and the fly likes how can remove number of  keys from session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how can remove number of  keys from session?" Watch "how can remove number of  keys from session?" New topic
Author

how can remove number of keys from session?

kiran kumar
Greenhorn

Joined: May 24, 2008
Posts: 18
Hi,
How can we remove number of keys(or all at once) means more than one attribute in session if I want to remove one attribure I will write as remove.attribure(s1) ; if I want to remove more than one how can we write.
can we write as remove.attribute(s1); remove.attribute(s2);


Thanks & Regards,<br />Bhuvan Samrat.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

getAttributeNames will return an enumeration of the session attribute names.

You can iterate over that enumeration and remove the attributes by name from within your loop.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

yes..you have to do mutiple time

but please Note this

----------------------------------------------------------------
session.removeAttribute("key1")...session.removeAttribute("keyn")

-----------------------------------------------------------------
kiran kumar
Greenhorn

Joined: May 24, 2008
Posts: 18
Hi venkat,
I know it .
Michael Bond
Greenhorn

Joined: Apr 08, 2008
Posts: 4
What number of keys are you tryin to remove?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how can remove number of keys from session?