1

I am creating a TreeMap bean. I want to pass this around in the session scope. However, I need to reset/clear this TreeMap bean.

This is how I am declaring my bean:

<jsp:useBean id="foo" class="java.util.TreeMap" scope="session"/>

Any ideas on how to clear/reset the usebean (and keep using the same id) would be appreciated.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jonathan Hult
  • 1,351
  • 2
  • 13
  • 19

1 Answers1

4

If you use c:set JSTL tag and pass in null, the variable will be removed. Another way to remove it to use c:remove

So

<c:remove var="foo" scope="session"/>

or

<c:set var="foo" scope="session" value="nullVar"/>

where nullVar evaluates to null

ryanprayogo
  • 11,587
  • 11
  • 51
  • 66
Basanth Roy
  • 6,272
  • 5
  • 25
  • 25