- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to apply forEach tag in JSP?
The <c:forEach> tag is a commonly used tag because it iterates over a collection of objects. The <c:forTokens> tag is used to break a string into tokens and iterate through each of the tokens.
Attribute
The <c:forEach> tag has the following attributes −
Attribute | Description | Required | Default |
---|---|---|---|
items | Information to loop over | No | None |
begin | Element to start with (0 = first item, 1 = second item, ...) | No | 0 |
end | Element to end with (0 = first item, 1 = second item, ...) | No | Last element |
step | Process every step items | No | 1 |
var | Name of the variable to expose the current item | No | None |
varStatus | Name of the variable to expose the loop status | No | None |
Example for <c:forEach>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <html> <head> <title><c:forEach> Tag Example</title> </head> <body> <c:forEach var = "i" begin = "1" end = "5"> Item <c:out value = "${i}"/><p> </c:forEach> </body> </html>
The above code will generate the following result −
Item 1 Item 2 Item 3 Item 4 Item 5
- Related Articles
- How to apply if tag in JSP?
- How to apply choose tag in JSP?
- How to apply forTokens tag in JSP?
- I want to create a custom tag in JSP. How to write a custom tag in JSP?
- How to apply a tag to the azure resource group using PowerShell?
- How can I create custom tag in JSP which can accept attribute from parent jsp page?
- What is the use of tag in JSP?
- What is the use of tag in JSP?
- What is the use of tag in JSP?
- How to terminate javascript forEach()?
- How to break forEach() method in Lodash?
- How to stop forEach() method in JavaScript?
- What are the standard attributes that should be passed to a custom tag in a JSP page?
- I am facing problem in using include directive tag in jsp. Please share a working example.
- How to use action in JSP?

Advertisements