JSTL Core Tags

tutorial and example
tutorial and example

In JSTL, core tags are most frequently used tags that provides variable support, manages URL and control the flow of JSP page. To use JSTL it is required to associate the below URL in your JSP page: –

It is not mandatory to use ‘c’ in the prefix of JSTL core tag. You can also use any other character or word. But as a convention, it is better to use it.

Core Tags

Here, is the list of JSTL core tags: –

  • <c:out> tag: – This tag is used to print statements or results. It works as an alternative of <%=expression %> tag.
  • <c:set> tag: – This tag is used to declare the variable with its value and scope.
  • <c:remove> tag: – This tag is used to remove the attributes.
  • <c:if> tag: – This tag works as a conditional statement and used for testing conditions.
  • <c:choose> tag: – The role of this tag is similar to switch statement.
  • <c:when> tag: – The role of this tag is similar to case in switch statement. Thus, it test the conditions.
  • <c:otherwise> tag: – This tag behaves similar to default in switch statement. Thus, it executes when no condition for <c:when tag> matches.
  • <c:catch> tag: – This tag is used to handle the exceptions.
  • <c:import> tag: – This tag includes another files of any type such as JSP, HTML, XML etc. to current JSP file.
  • <c:forEach> tag: – This is an iteration tag used to traverse the elements.
  • <c:param> tag: – This tag is used to add the parameters.
  • <c:url> tag: –

Example of JSTL core Tag

In this example, the functionality of certain JSTL core tags are shown in an easy way.

index.jsp

Output: