VisualBuilder
  Home > Jsp > Tutorials > Introduction To Core Taglib -2 - JSP Tutorial
Tell a friend
Link to us
Total Members
      Members: 84661
     
Sitemap Forum Chat
Home
JSP Tutorial Home
1 . Introduction to JSP
2 . Why use JSP?
3 . JSP compared to ASP,ASP.NET and Servlets
4 . JSP architecture
5 . Setting up the JSP environment
6 . Creating your first JSP page
7 . Using JSP tags
8 . Declaration tag
9 . Expression tag
10 . Directive tag
11 . Scriptlet tag
12 . Action tag
13 . Creating your second JSP page
14 . Implicit Objects
15 . Creating a Form
16 . Processing a Form
17 . Creating a Form (more elements)
18 . Processing a Form (more elements)
19 . Processing a Form (more elements)
20 . Getting Client Info
21 . Review and next steps
22 . Beans scopes in JSP
23 . JSP Bean scope examples
24 . Uploading Application in JSP.
25 . Modularization in JSP
26 . Exception Handling in JSP-1
27 . Exception Handling in JSP-2
28 . Session Tracking in JSP
29 . Security in JSP -2
30 . Security in JSP -1
31 . Internationalization in JSP application
32 . Introduction To Expression Language.
33 . Introduction to Tag libraries
34 . Introduction To Core Taglib -1
35 . Introduction To Core Taglib -2
36 . Function Taglib
37 . Database Handling in JSP.
38 . Creating User Defined Custom Tag -1
39 . Creating User Defined Custom Tag -2
40 . Best Practices in JSP
 
 
JSP Home
JSP Members (18709)
JSP Member Articles ( 11 )
JSP Discussion (71)
JSP Q & A ( 87 )
- JSP Ask Question
- JSP Questions
- JSP Unanswered Questions
JSP Resources
JSP Source Code (172)
JSP Articles (34)
JSP Blogs (333)
JSP Jobs (0)
JSP Components (10)
JSP Books (9)
JSP Websites (13)
JSP News (12)
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.Net Security,Internationalisation And Deployment
ASP.NET Tutorial
C# Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (451 )
Source Code (3275 )
Articles (359 )
Books (372 )
Components (1596 )
News (892 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise

Jsp Tutorial
 Introduction To Core Taglib -2
  << Prev: Introduction To Core Taglib -1 Next: Function Taglib >>

Iterator Tags



The <c:forEach> tag allows you to iterate over a collection of objects. You specify the collection via "items" attribute, and the current item is available through a variable named given in the "var" attribute. A large number of collection types are supported by <c:forEach>, including all implementations of java.util.Collection and java.util.Map. If given collection is of type java.util.Map, then the current item will be of type java.util.Map.Entry, which has the following properties:



  • key: The key under which the item is stored in the underlying Map

  • value: The value that corresponds to the key


Arrays of objects as well as arrays of primitive types (for example, int) are also supported. For arrays of primitive types, the current item for the iteration is automatically wrapped with its standard wrapper class (for example, Integer for int, Float for float, and so on).

 


<c:forEach var="item" items="collection">
</c:forEach>

or


<c:forEach begin="0" end="10" varStatus="status" step="1" >


</c:forEach>


 


URL Tags



The <c:url> tag is used to create the URL for the submit actions or the hyperlinks. The <c:url> tag is used to create the URL variable and <c:param> is used to add the parameters in the <c:url> tag. The syntax is as follows:-


 


<c:url var="var" value="..." >
<c:param
name="param1" value="val1" />
</c:url>


Example:-


<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%
   
String[] value = new String[10];
    value[0]="one";
    value[1]="two";
    value[2]="three";
    value[3]="four";
    value[4]="five";
    value[5]="six";
    value[6]="seven";
    value[7]="eight";
    value[8]="nine";
    value[9]="ten";
    pageContext.setAttribute("values",value);
%>
<b>
Iterator For loop <br></b>
<c:forEach
var="item" varStatus="status" items="${values}">
    Place <c:out value="${status.index}"/> value is <c:out value="${item}"/><br>
</c:forEach>
<br>
<b>
Coventional For Loop<br></b>
<c:forEach
begin="0" end="10" varStatus="status" step="1" >
    Place <c:out value="${status.index}"/> value is <c:out     value="${values[status.index]}"/><br>
</c:forEach>


 


<c:url var="yahoo" value="http://www.yahoo.com"/>


<a href="${yahoo}">yahoo url</a>


 



  << Prev: Introduction To Core Taglib -1 Next: Function Taglib >>
Jsp Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
 
ADVERTISEMENT
Partner List
Code Project
ASP Alliance
More
 
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising