File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing session attributes with regex

 
Kumara Sharma
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to remove all the session attributes based on a pattern match.
Ex: Attribute keys being: book_firefox, book_chrome, etc.

Is there a way to remove all the attributes that start with book_* in a single statement.
HttpSession.removeAttribute(String) takes a single string as parameter, so how to achieve this?
 
Harsha Ka
Ranch Hand
Posts: 45
Eclipse IDE Java
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One possible way is using getAttributeNames() to get all the objects and iterate over these and check the key, and if the object key is matching your regex validation, remove this object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic