JSTL(JSP Standard Tag Library) is a collection of custom tags that provide common functionalities like flow control, database operations, etc. JSTL tags can be embedded in Java Server Pages just like other HTML tags. It is convenient for front-end developers to work with HTML-like tags for including logic in webpages rather than writing Java code in scripts. To use JSTL tags, the following dependencies must be included in pom.xml in a maven project:
Alternatively, you can download the jar files from this link. JSTL tags are grouped into five major categories:
This article focuses on JSTL Core tags.
Core tags in JSTL are used for iteration, conditional logic, url management, handling exceptions, redirect, etc.
The following tags are included in the JSTL Core tag library:
It is used to set a value to a variable that can be used within the specified scope in a JSP.
Example:
Output:
My Name is John
removes the specified variable.
Example:
Output:
My Name is John My Name is
In the above example, the variable name is removed, therefore, the second doesn’t display the name.
It is used to display the content on the web page similar to the expression tag (
Example:
Output:
We are learning JSTL Core Tags
used to iterate over a collection or an array.
Example:
Output:
1 3 5 7 9 10 12 15 14 9
It is used to include the contents from relative or absolute urls within or outside the server.
Example:
It is used with or to send parameters in the url to the imported or redirected pages respectively.
It is used to redirect a page to another url.
Example:
Output:
Welcome John!
It is used to catch any exception of type Throwable that occurs in the body.
Example:
Output:
java.lang.ArithmeticException:/by zero
It is used to include the conditional statement in the java server pages. Body content is evaluated only when the condition evaluates to true.
Example:
Output:
Qualified!!
It is used to iterate over given tokens separated by the specified delimiters.
Example:
Output:
10 20 30 40 50
It is used to include a conditional statement on the page. It allows multiple conditions similar to if-else ladder or switch case statements.
c:choose>: It marks the beginning of conditional and encloses and .
c:when>: It is used to provide the condition and encloses the body to be executed if the condition evaluates to true.
c:otherwise>: It encloses the content to be executed if all the above conditions evaluate as false.
Example:
Output:
A Grade
It is used to create a formatted url along with parameters using a nested tag.
Example:
Output:
Click hereLike Article -->
The <c:set> tag is used for variable creation and assignment in JSP pages. In this article, we will delve into the JSTL Core <c:set> tag, provide code samples, and illustrate the expected outputs. It is used to set the result of an expression evaluated in a "scope". Prerequisite of the topicGood understanding of Java EE web project deve
3 min read JSTL Core <c:out> TagJava Server Pages (JSP) is a technology used to create web applications with the popular programming language Java. With JSP we can write Java code inside a HTML page, making it easier to develop web applications. To enhance the feature set and usability of JSPs, Java Server Pages Standard Tag Library (JSTL) was introduced. By using JSTL, we can si
5 min read JSTL Core <c:import> TagJavaServer Pages (JSP) is a technology through which developers can create dynamic, server-side web applications. The Java code can be easily integrated into HTML templates to generate dynamic content. The JavaServer Pages Standard Tag Library (JSTL), is one of the main components of JSP. The <c:import> tag is one of the several tags offered
2 min read JSTL Core <c:catch> TagThe JSTL Core <c:catch> tag is used in exception handling to handle errors that occur during runtime by catching any Throwable object(an exception) in its body. Attributes of <c:catch> TagThe <c:catch> tag has a single optional attribute: var: The name of the page-scoped variable to store the exception in. If this attribute is not
2 min read JSTL Core <c:choose>, <c:when>, <c:otherwise> TagJavaServer Pages Standard Tag Library (JSTL) is a tool for web application development in Java. It provides a collection of tags that allow developers to implement the logic as code for JSP applications. In this article, cover these tags with explanations to help you learn their functionality. JSTL tags <c:choose>, <c:when>, and <c:o
6 min read JSTL Core <c:remove> TagThe JSTL Core <c:remove> tag is used to remove a variable or attributes from a specific scope in your JSP application used for making web pages in Java. It can be used to clean up any scoped resources that a JSP is responsible for. The <c:remove> tag in JSP development. It allows you to remove a variable or attributes from one of the fo
2 min read JSTL Core <c:forEach> TagThe JSTL Core <c:forEach> tag is used to iterate over a collection of objects or a range of values. It is the most commonly used JSTL tag because it can be used to implement a variety of functionality. Attributes of <c:forEach>The <c:forEach> tag has the following attributes: var: Variable to point to the current item in the colle
3 min read JSTL Core <c:url> TagTo construct and manage URLs within JSP pages we have this tag <c:url> for your JSP application. It is among the most fundamental tags within JSTL's core library. Purpose of <c:url> tag. Uses of JSTL Core <c:url>The <c:url> tag primarily serves two key purposes: URL Formatting: The <c:url> tag effectively formats URLs,
3 min read JSTL Core <c:redirect> TagJSTL - "JavaServer Pages Standard Tag Library" is a collection of useful JSP tags, that are the core foundation of JSP & aid in the application development. JSP technology is used to design the front-end UI of the web application, and it was developed to provide separation between Presentation logic and Business Logic. JSP can be thought of as
4 min read JSTL Core <c:if> TagTo control the execution sequence within a JSP page, use the conditional JSTL Core <c:if> tag. When an expression is evaluated by the tag, the body of the tag is only included if the expression is determined to be true. Syntax <c:if> tag<c:if test="$
JSTL(JSP Standard Tag Library) is a collection of custom tags that provide common functionalities like flow control, database operations, etc. JSTL tags can be embedded in Java Server Pages just like other HTML tags. It is convenient for front-end developers to work with HTML-like tags for including logic in webpages rather than writing Java code i
8 min read JSTL SQL TagsJSTL is a collection of custom tags that provide common functionalities like flow control, database operations, etc. JSTL tags can be embedded in Java Server Pages just like other HTML tags. It is convenient for front-end developers to work with HTML-like tags for including logic in webpages rather than writing Java code in scriplets. To use JSTL t
5 min read JSTL Formatting tagsJSTL stands for JavaServer Pages Standard Tag Library. It is introduced in the JSP 2.0 version to simplify the JSP. By using JSTL, JSP becomes a 100% tag-based application. JSTL can provide the group of tags that are used to perform the tasks in the JSP pages without using the Java code. JSTL tags are divided into the Five types Formatting tags, Co
3 min read Spring MVC JSTL ConfigurationJavaServer Pages Tag Library (JSTL) is a set of tags that can be used for implementing some common operations such as looping, conditional formatting, and others. Here we will be discussing how to use the Maven build tool to add JSTL support to a Spring MVC application. also, you'll learn how to activate JSTL tags in a Spring MVC application. Step
1 min read Spring MVC - Basic Example using JSTLJSP Standard Tag Library (JSTL) is a set of tags that can be used for implementing some common operations such as looping, conditional formatting, and others. JSTL aims to provide an easy way to maintain SP pages The use of tags defined in JSTL has Simplified the task of the designers to create Web pages. They can now simply use a tag related to th
8 min read Spring MVC - Iterating List on JSP using JSTLJSP Standard Tag Library (JSTL) is a set of tags that can be used for implementing some common operations such as looping, conditional formatting, and others. JSTL aims to provide an easy way to maintain SP pages The use of tags defined in JSTL has Simplified the task of the designers to create Web pages. They can now simply use a tag related to th
6 min read Spring MVC - JSTL forEach Tag with ExampleJSP Standard Tag Library (JSTL) is a set of tags that can be used for implementing some common operations such as looping, conditional formatting, and others. JSTL aims to provide an easy way to maintain SP pages The use of tags defined in JSTL has Simplified the task of the designers to create Web pages. They can now simply use a tag related to th
6 min read JSTL fn:replace() FunctionThe JSTL fn:replace() function or method in JSP (Java Server Pages) is mainly used for the manipulation of strings. This function allows developers to replace the occurrence of a specified substring with another substring in the given input string. This article will see the Syntax, parameters, and two practical examples of the fn:replace() function
2 min read JSTL fn:substringAfter() FunctionIn the main string, if we want to return the subset of the string followed by a specific substring then we can use the JSTL fn:substringAfter() Function. JSTL substringAfter() FunctionThis function mainly returns the portion of the string that comes after the given string value. In this article, we will see the detailed Syntax of the fn:substringAf
2 min read JSTL fn:containsIgnoreCase() FunctionIn the input string, if we need to check whether the input string has the specified string or not by ignoring its case then we can use the JSTL fn:containsIgnoreCase() Function. In this article, we will see the detailed Syntax of the fn:containsIgnoreCase() function along with its parameters, we will also see the practical implementation of this fu
2 min read JSTL fn:substring() FunctionIn JSTL, the fn:substring() function is used to extract or retrieve the part of a given input or specified string, by starting from the start index to the end index [optional]. This function is mainly used for string manipulation tasks by many developers. In this article we will explore the Syntax along with the Parameters of the JSTL fn:substring(
2 min read JSTL fn:contains() FunctionIn JSTL, the fn:contains() function is mainly used to check the input substring is present within the given string. This function returns the boolean value representing the result in True or False form. This function simplifies the substring presence check tasks in Java Server Pages. In this article, we will see the syntax, parameters, and practica
2 min read JSTL fn:toUpperCase() FunctionIn JSTL, the fn:toUpperCase() function is used to transform all the characters in a specified string to uppercase. If the input string is in lowercase, then this function can convert all the characters into uppercase. In this article, we will see the Syntax along with Parameters and detailed implementation of JSTL fn:toUpperCase() Function in terms
1 min read JSTL fn:toLowerCase() FunctionIn JSTL, the fn:toLowerCase function converts all the characters of the input or specified string into the lowercase format. This allows the developers to transform the string case with the JavaServer Pages and also ensures the proper representation of text in lowercase. In this article, we will see the Syntax along with parameters and also the pra
2 min read JSTL fn:trim() FunctionIn JSTL the fn:trim() function is used to remove the leading and trailing whitespaces in the given input or specified string. The fn:trim() function also helps in properly cleaning up and standardizing the formatting of strings within the JSP. In this article, we will see the detailed syntax and the parameters of this function. We will also see the
2 min read JSTL fn:split() FunctionThe JSTL fn:split() function is used to split the input string into an array of different substrings based on the delimiter. This function is helpful to the parsing of strings within the JavaServer Pages, which also allows the developers to extract the substring from the main string. In this article, we will see the syntax along with the parameters
2 min read JSTL fn:indexOf() FunctionFor JSTL-based applications, fn:indexOf() function is used to get the first occurrence index or the position of the substring in the main string. This function- returns the position of the substring if it is found in the main string. If it is not found, then it returns the -1 value and prints on the screen.In this article, we will see the syntax of
2 min read JSTL fn:length() FunctionIn JSTL, the fn:length() function is mainly used to specify the length or size of a collection, array, or string in JSP. This function returns the number of elements in the given object as input. Used to retrieve the size or length information within the JSTL expressions. The fn:length() function is part of the JSTL core tag library. In this articl
2 min read JSTL Formatting <fmt:formatNumber> TagIn JSTL the <fmt:formatNumber> tag is mainly used to format the numeric value according to the specified localization setting, which also includes the grouping separators, currency symbols, and decimal separators. This function mainly simplified the presentation of numeric data in JSP by offering control over how the numbers should be display
3 min read JSTL Formatting <fmt:formatDate> TagIn developing JSTL applications, we used date and time as one of the representative components. But in some cases, the date or time which is displayed is to be more sorted and in a proper format. So to solve this, we can use the JSTL Formatting <fmt:formatDate> Tag. tag is used to format the time and date according to any custom pattern. In t