• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can remove number of keys from session?

 
kiran kumar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes..you have to do mutiple time

but please Note this

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

-----------------------------------------------------------------
 
kiran kumar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi venkat,
I know it .
 
Michael Bond
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What number of keys are you tryin to remove?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic