aspose file tools*
The moose likes JSP and the fly likes how to use arraylist in jstl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to use arraylist in jstl" Watch "how to use arraylist in jstl" New topic
Author

how to use arraylist in jstl

nizams uddin
Greenhorn

Joined: Jul 31, 2006
Posts: 15
ArrayList allBusinessCenterList = new allBusinessCenterList();
allBusinessCenterList.add("1");
allBusinessCenterList.add("12");
allBusinessCenterList.add("13");

how to convert the below code using jstl
assume arraylist a normal list with values and does not contain any bean value.

<% for(int i =0;i <allBusinessCenterList.size();i++){%>
uot.println(allBusinessCenterList.get(i));
<% } %>
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Make sure you include this header

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

then your code:

<c:forEach var="businessCenter" items="${allBusinessCenterList}">
${businessCenter}
</c:forEach>


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
nizams uddin
Greenhorn

Joined: Jul 31, 2006
Posts: 15
Thank you for the suggestion.
but i had allready tried that and it was not working, so i posted to the gruop.
i tried with the sample code that you gave but it is still not responding.
i have inserted the tag lib for c


Originally posted by ni ni:
ArrayList allBusinessCenterList = new allBusinessCenterList();
allBusinessCenterList.add("1");
allBusinessCenterList.add("12");
allBusinessCenterList.add("13");

how to convert the below code using jstl
assume arraylist a normal list with values and does not contain any bean value.

<% for(int i =0;i <allBusinessCenterList.size();i++){%>
uot.println(allBusinessCenterList.get(i));
<% } %>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

ni ni
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1017
Timothy Sam's response was entirely correct.
If its not working for you, then you have a configuration issue.

See the FAQ entry on JSTL: http://faq.javaranch.com/view?ElOrJstlNotWorkingAsExpected

If that does not help you, then reply back with answers to the following questions
- What server are you using (version)
- What version of JSTL are you using
- Any error messages / unexpected output - ie what is WRONG with your page other than "it doesn't work".
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Actually, allBusinessCenterList has to be in one of the following scopes: page, request, session or application.
If the code you've posted is in a scriptlet, you won't be able to access the array, unless you put it in one of the above scopes.

As Stefan said, if you've got an error message, please post it.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use arraylist in jstl