JSTL Core tag – remove() : Function



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 normally particularly helpful, but it can aid in ensuring that a JSP cleans up any scoped resources it is responsible for.

Attribute:

The <c:remove> tag has following attributes:

Attribute Description Required Default
var Name of the variable to remove Yes None
scope Scope of the variable to remove No All scopes

JSTL Example :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>JSTL Tag Example</title>
</head>
<body>

<c:set var="num" scope="session" value="${1234}"/>
<p>Before Remove Value : <c:out value="${num}"/></p>

<c:remove var="num"/>
<p>After Remove Value : <c:out value="${num}"/></p>

</body>
</html>

Output :

Before Remove Value : 1234
After Remove Value  :