JSTL c:remove Example

JSTL c:remove Example explains about How to use c:remove tag inside JSTL

In your application, you need to remove a variable after its use, In that case you can use JSTL c:remove Tag

c:remove Tag is available as a part of JSTL core tags, JSTL c:remove Tag will remove a given variable from a specified scope such as page,request,session or application

If we are not specified any scope for a variable which we want to remove, it will check whether the given variable is available with any scope, if it finds it will be removed, The order of the check is like following page, request, session & application

You can see the below example demonstrating the usage JSTL c:remove Example inside JSTL

Required Libraries

You need to download

  1. Tomcat 7
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

JSTL c:remove Example

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<title>JSTL c:remove Tag</title>
	<!-- JSTL c:remove Example -->
	<!-- Default scope is page, if scope is not specified -->
	<c:set var="name" value="Rockey" />
	<c:set var="age" scope="request" value="25" />
	<c:set var="address" scope="session" value="C/3343" />
	<c:set var="city" scope="application" value="Delhi" />
	<!-- remove name from all scopes, if not specified -->
	<c:remove var="name" />
	<!-- remove age from request scope -->
	<c:remove var="age" scope="request" />
	<!-- remove address from session scope -->
	<c:remove var="address" scope="session" />
	<!-- remove city from application scope -->
	<c:remove var="city" scope="application" />
	<c:out value="${age}" />
	<br /> Name
	<c:out value="${name}" />
	<br /> Address
	<c:out value="${address}" />
	<br /> City
	<c:out value="${city}" />
	<br />


Your email address will not be published. Required fields are marked *