<c:remove> Tag
The <c:remove>
tag is used to remove a variable, and you can specify the scope of this variable. If not specified, it defaults to the scope where the variable first appeared.
This tag is not particularly useful, but it can be used to ensure that JSP completes cleanup tasks.
Syntax
<c:remove var="<string>" scope="<string>"/>
Attributes
The <c:remove>
tag has the following attributes:
Attribute | Description | Required | Default Value |
---|---|---|---|
var | The name of the variable to be removed | Yes | None |
scope | The scope of the variable | No | All scopes |
Example
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:remove Tag Example</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<p>salary variable value: <c:out value="${salary}"/></p>
<c:remove var="salary"/>
<p>Value after removing salary variable: <c:out value="${salary}"/></p>
</body>
</html>
The output is as follows:
salary variable value: 4000
Value after removing salary variable: