Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
JSP
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

JSTL: forEach and status

                          

It is not a good programming practice to use directive to set the attribute in a bean or a map when we are using the jstl. Instead of using directive we can use the <c:set> tag of jstl. 

In this program we are going to use the tag <c: set>. By using this tag we are setting an attribute variable var. If there is not a page- scoped attribute named movies, then this tag creates one, it will assume that the value attribute is not null. If the value is null then it will delete the var attribute. The var tag is required. The attribute scope is optional in this tag.  In <c: forEach> tag we have used some attributes like var which will help us to iterate the values i.e. movies. The attribute items which will help us to get the attribute. The varStatus attribute makes a new variable that holds an instance of javax.servlet.jsp.jstl.core.LoopTagStatus.  Use <c:out> to display the result to the browser.

The forEach has one scoped variable called count. The LoopTagStatus class has a count property which gives us the current value of the iteration counter.

The code of the program is given below:

 

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<c:set var="movies" value="Sholay, Maine Pyar kiya, Jai Santoshi Maa, Krish" scope="page" />
<html>
<head>
<title>forEach and status</title>
</head>
<body>
<h1>The forEach has one scoped variable called 'count', it tells the 
current position of the element within the collection. </h1>
<c:forEach items="${pageScope.movies}" var="currentName" varStatus="status" begin="0" end="3" step="1">
Movie Names :<c:out value="${status.count}" /> is
<c:out value="${currentName}" /> <br />
</c:forEach>
</body>
</html>

The output of the program is given below:

Download this example.

                          

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
JavaScript regular ex
PHP Selecting differen
get object
read from web-inf fold
logout page in jsp
Hash Map
hibernate config.xml
checkLogin
hash map for loop
disable jtree nodes
String to array in jav
difference between exe
array sum
two dimensional array
WriteaprograminCorCdem
native methods
SOA tutorials
application
Java Applet Building J
given string is palind
java codes for multipl
HSSFHeader
breakะà????ะà????à
HTTP post data in wick
file upload j2ee
How to iterate over li
how to long progrm ja
Request Object In JSP
MULTIPLE SELECT COMBO
wth_small
program for update que
panelgrid with its ren
adding header and foot
â???â?¬Ð°â???â?¬â??â??
retrive data from data
Copy One Database Tabl
Generated
java drop down list
JTable size
Photoshop Change a wal
list switch
comparable
Quartz Tutorial
iReport
ActionSupport
த���த��?
month
java bean insert conne
insert image from jsp
Tree Grid using flex
Try catch in JSP
linked lists in C
upload and chage the i
Insert Data into Datab
Ant
Catching Exception usi
dynamic array value
byte
break�����??
guid
java string
HTML Getting Started H
hssf
Cloneable
fourth and fifth norma
code fro finding index
rmi example
how to create tree usi
J2ME Gauge
retrive the max EMPNO
hide table in jsp
export to excel
Bioinformatics
ASP File Manipulation
java bean
MULTIPLE SELECT COMBO
ip address programming
Photoshop Web Layouts
read how many words on
wait
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.