count to 10 example using jstl

4
JSTL: for each and status <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <c:set var="names" value="Joe, Rob, Rosy, Sissi" scope="page" /> <html>  <head>  <title>forEach and status</title>  </head>  <body>  <h1>The forEach tag exposes a scoped variable called 'count', which  is the position of the current iteration of the collection.</h1>  <h2>(Note, it is <i>not</i> the position of the element in the  underlying collection)</h2>  <c:forEach items="${pageScope.names}"  var="currentName"  varStatus="status"  begin="0"  end ="3"  step="2"  >  Family member #<c:out value= "${status.count}" /> is  <c:out value="${currentName}" /> <br />  </c:forEach>  </body> </html>  JSTL: another for each and status <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%  synchronized (pageContext) {  String[] names = { "Joe", "Rosy", "Petter", "Rob"};  pageContext.setAttribute( "names", names, PageContext.PAGE_SCOPE);  } %> <html>  <head>  <title>forEach and status</title>  </head>  <body>

Upload: prabhakarbokka

Post on 09-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

8/7/2019 Count to 10 Example using JSTL

http://slidepdf.com/reader/full/count-to-10-example-using-jstl 1/4

8/7/2019 Count to 10 Example using JSTL

http://slidepdf.com/reader/full/count-to-10-example-using-jstl 2/4

8/7/2019 Count to 10 Example using JSTL

http://slidepdf.com/reader/full/count-to-10-example-using-jstl 3/4

8/7/2019 Count to 10 Example using JSTL

http://slidepdf.com/reader/full/count-to-10-example-using-jstl 4/4