BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

JSTL <c:remove> Core Tag

Last Updated: November 28, 2013 by Chaitanya Singh | Filed Under: JSTL

<c:remove> tag is used for removing an attribute from a specified scope or from all scopes (page, request, session and application).

Example

In the below example, first I have set two variables using <c:set> tag and then I have removed one of them using <c:remove> tag. As you can see in the output screenshot – when I tried to display both the variables, for the second attribute the page didn’t get any value and printed the default value using default attribute of <c:out> tag.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Example of c:remove tag</title>
</head>
<body>
<c:set var="Site" scope="session" value="BeginnersBook.com"/>
<c:set var="author" scope="session" value="Chaitanya"/>
<c:remove var="author"/>
<a href="display.jsp">check attributes</a>
</body>
</html>

display.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:out value="${Site}"/><br>
<c:out value="${author}" default="Attribute has no value"/>

c-remove-example

c-remove-example2

Scope attribute of <c:remove> tag

Above we have coded like this

<c:remove var="author"/>

This above code removes an attribute from all the scopes (page, session, application, request). In order to be specific we must need to specify the scope attribute inside <c:remove>  tag, like I did below – The below JSTL statement will remove the variable var from session scope.

<c:remove var="author" scope="session"/>

Top Related Articles:

  1. JSTL <c:redirect> Core Tag
  2. JSTL <c:out> Core Tag
  3. JSTL <c:set> Core Tag
  4. JSTL <c:url> Core Tag
  5. JSTL <c:choose>, <c:when>, <c:otherwise> Core Tags

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

JSTL Core Tags

  • c:out
  • c:set
  • c:remove
  • c:if
  • c:choose
  • c:when
  • c:otherwise
  • c:catch
  • c:import
  • c:forEach
  • c:forTokens
  • c:param
  • c:url
  • c:redirect
JSTL Functions
  • fn:contains()
  • fn:containsIgnoreCase()
  • fn:indexOf()
  • fn:escapeXML()
  • fn:join() & fn:split()
  • fn:length()
  • fn:startsWith()
  • fn:endsWith()
  • fn:substring()
  • fn:substringAfter()
  • fn:substringBefore()
  • fn:trim()
  • fn:toUpperCase()
  • fn:toLowerCase()
  • fn:replace()

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap