JSTL Core Tags Library

The Core tag library is the collection of the JSTL core tags in the JSP pages. These tags are used for manipulating data in JSP pages. This is used for iterating on data collection, setting parameter etc.

The Syntax for the JSTL Core Tag

<% @taglib uri= “http://java.sun.com/jsp/jstl/core”  prefix= “c” %>

Prefix c is used to refer to this tag in the jsp.

JSTL Core Tags

The JSTL core tags can be categorized based on their functions as below:

  • Variable support– This category includes tags like remove,set
  • Flow control– This category includes tags like choose, when,otherwise,forEach,forTokens,if
  • URL management– This category includes tags like import,redirect,url
  • Miscellaneous– This category includes tags like catch,out

Each of these tags are explained below:

  • <c:out> – The c:out tag is used to print or display the result of an expression.
  • <c:set> – This tag is used to set the value of variable into the given scope.
  • <c:remove> – The c:remove tag is used to remove the variable from the specified scope.
  • <c:catch> – c:catch tag is used to handle the exceptions that can be raised by any of the tag which located inside the body of the <catch> tag.
  • <c:if> – This tag evaluates an expression and displays its body content only if the expression is true.
  • <c:choose> – The <c:choose> tag executes the conditional block statements which is embedded with the sub-tags <c:when> and <c:otherwise>.
  • <c:when> – The <c:when> tag is like the block of if control statements which executes when the condition is true.
  • <c:otherwise> – The <c:otherwise> tag is evaluated if when or nested when tag attribute test condition is not evaluated to be true.
  • <c:import> – The <c:import> tag is used to include the content of another resource in the current JSP.
  • <c:forEach> – The <c:forEach> tag is used to iterate over a collection of data such as arrays.
  • <c:forToken> – The <c:forToken> tag is used to break a string into tokens and iterate through each of the tokens.
  • <c:param> – The <c:param> tag add the parameter and their values to the output of <c:url> and <c:redirect> tag.
  • <c:redirect> – It is used to redirect control to other pages within the web application.
  • <c:url> – The <c:url> tag formats a URL into a string and stores it into a variable.

Next tutorials explains each tag in detail.

Previous Tutorial : What is JSTL Tags?  ::  Next Tutorial : JSTL Core c:set Tag

Leave a Reply

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

Pin It on Pinterest

Share This

Share this post with your friends!