How to remove a java variable from current scope in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

The <c:remove> tag removes a variable from either a specified scope or the first scope where the variable is found (if no scope is specified). This action is not particularly helpful, but it can aid in ensuring that a JSP cleans up any scoped resources it is responsible for.


The <c:remove> tag has the following attributes −

varName of the variable to removeYesNone
scopeScope of the variable to removeNoAll scopes


<%@ taglib uri = "" prefix = "c" %>
      <title><c:remove> Tag Example</title>
      <c:set var = "salary" scope = "session" value = "${2000*2}"/>
     <p>Before Remove Value: <c:out value = "${salary}"/></p>
     <c:remove var = "salary"/>
     <p>After Remove Value: <c:out value = "${salary}"/></p>

The above code will generate the following result −

Before Remove Value: 4000
After Remove Value:
Published on 22-Mar-2019 10:01:18