JSTL Core <c:remove> Tag

Introduction :

JSTL provides the <c:remove> tag to remove the value associated with the variable. This tag deletes the variable from the specified scope. But in case of the scope is not specified, it deletes the variable from the first scope where it is found.


Attribute Of <c:remove> :

The <c:remove> tag has following attributes:

JSTL c:remove tag

Introduction :

JSTL provides the <c:remove> tag to remove the value associated with the variable. This tag deletes the variable from the specified scope. But in case of the scope is not specified, it deletes the variable from the first scope where it is found.


Attribute Of <c:remove> :

The <c:remove> tag has following attributes:

JSTL c:remove tag



Example of <c:remove> Tag :

In the example given below we will describe you how to use the <c:remove> tag in jsp. In the example I have first set the value of a variables using <c:set> tag and then removed the one value using <c:remove> tag of JSTL core tag library. So as an output you will see the values that I set to variables 'var1' & 'var2' but in the further step you will see there is only value and the other value is removed. This is because I removed the value of the variable 'var1' using <c:remove> var="var2" />


JstlRemoveTag.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>JSTL Example</title>
</head>
<body>
	<h3>JSTL Core Tag remove Example.</h3>
	<c:set var="var1" value="Mukesh" />
	<c:set var="var2" value="Kumar" />
	<h4>Values of both variables are ....</h4>
	<b>Value of var1 : </b>
	<c:out value="${var1}" />
	<br>
	<b>Value of var2 : </b>
	<c:out value="${var2}" />
	<br>
	<!-- Removing the value associated to variable var2 -->
	<c:remove var="var2" />
	<h4>After Removing the value of var2 variable ....</h4>
	<b>Value of var1 : </b>
	<c:out value="${var1}" />
	<br>
	<b>value of var2 : </b>
	<c:out value="${var2}" />
	<br>
</body>
</html>

Output in Browser :

JSTL c:set tag


Download this example(src+lib) developed in eclipse





comments powered by Disqus