JSTL forTokens tag is another tag in core JSTL library to support Iteration or looping. It effectively compliments, more useful <c:forEach> tag, by allowing you to iterate over comma-separated or any delimited String. You can use this tag to split string in JSP and can operate on them individually. forTokens tag has similar attributes like forEach JSTL tag except one more attribute called delims, which specifies delimiter. For example to iterate over colon-separated String "abc:cde:fgh:ijk", delims=":".
Ads 970x90
Tampilkan postingan dengan label JSTL. Tampilkan semua postingan
Tampilkan postingan dengan label JSTL. Tampilkan semua postingan
Selasa, 27 Juli 2021
Senin, 26 Juli 2021
JSTL foreach tag example in JSP - looping ArrayList
JSTL foreach loop in JSP
JSTL foreach tag is pretty useful while writing Java free JSP code. JSTL foreach tag allows you to iterate or loop Array List, HashSetor any other collection without using Java code. After the introduction of JSTL and expression language(EL) it is possible to write dynamic JSP code without using scriptlet which clutters jsp pages. JSTL foreach tag is a replacement of for loop and behaves similarly like foreach loop of Java 5 but still has some elements and attribute which makes it hard for first-timers to grasp it. JSTL foreach loop can iterate over arrays, collections like List, Setand print values just like for loop.
JSP - How to check if ArrayList is Empty using JSTL Example
There are multiple ways to check if an ArrayList is empty in JSP or not. For example, you can use the empty operator and the length function of JSTL to check if a list is empty or not. You can also use scriptlet, which allows you to insert Java code into JSP but that is not advisable because it makes it harder to maintain a JSP page. You can also write a custom tag but that is not required because JSTL provides you the necessary support. In this article, I'll show you two ways to check if a given list or ArrayList is empty or not on the JSP page without using the scriptlet. You guessed it right, we will use JSTL, the Java standard tag library to solve this problem.