<c:remove> Tag
The <c:remove> tag is used to remove a variable. 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 JSP completes cleanup work.
Syntax Format
<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 remove | Yes | None |
| scope | The scope to which the variable belongs | no | All scopes |
Example Demonstration
<%@ 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 标签实例</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<p>salary 变量值: <c:out value="${salary}"/></p>
<c:remove var="salary"/>
<p>删除 salary 变量后的值: <c:out value="${salary}"/></p>
</body>
</html>
The output is as follows:
salary 变量值: 4000 删除 salary 变量后的值:
Other Extensions
JSP Standard Tag Library