Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top