Easy Tutorial
❮ Jsp Syntax Jstl Function Indexof ❯

<c:remove> Tag

JSP Standard Tag Library

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

&lt;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>
&lt;c:set var="salary" scope="session" value="${2000*2}"/>
<p>salary variable value: <c:out value="${salary}"/></p>
&lt;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:

JSP Standard Tag Library

❮ Jsp Syntax Jstl Function Indexof ❯