InterviewSolution
| 1. |
Explain Jstl Foreach Tag With An Example? |
|
Answer» JSTL forEach TAG: This tag provides a mechanism for iteration within a JSP page. JSTL forEach tag works similarly to enhanced for loop of Java Technology. You can use this tag to iterate over an existing collection of items. For Example : <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="C" %> <HTML> Here the attribute items has its value as an EL expression which is a collection of ERROR messages. Each item in the iteration will be stored in a variable called message which will be available in the body of the forEach tag. JSTL forEach tag: This tag provides a mechanism for iteration within a JSP page. JSTL forEach tag works similarly to enhanced for loop of Java Technology. You can use this tag to iterate over an existing collection of items. For Example : <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> Here the attribute items has its value as an EL expression which is a collection of error messages. Each item in the iteration will be stored in a variable called message which will be available in the body of the forEach tag. |
|