aspose file tools*
The moose likes JSP and the fly likes JSTL forEach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL forEach" Watch "JSTL forEach" New topic
Author

JSTL forEach

Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
Hi all

I am trying to get this JSTL forEach tag to work with a collection. I have a UserBean that contains a collection of users, called users.

I first get a hold of the bean using <jsp:useBean> I am sure I am getting the bean ok because I can print out other attributes. Then I first tried the following to iterate over the users collection.



That hung up so then I tried this


which also hung up. Any thoughts?

Thanks,

AMD
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
opps sorry that extra quote was not in it

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

<c:forEach items="<jsp:getProperty
name="userBean"
property="users"/>
"var="user">


Completely not valid. You cannot use an action as the attribute value of another action.

Your second notation is more along proper lines.

What does "hung up" mean?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
hung up means that I eventually get a page not found after it sits spinning for awhile.

Thanks,

AMD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

Page not found?

That shouldn't have anything to so with anything on the page. After all, if it can't find it...

Do things work if you remove the action?
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
Yes if I remove the forEach stuff the page goes ok? Does the syntax on the second try look ok?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

Yes. Any errors in the logs?
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
I think it has something to do with how I am setting the list on the form bean.

I have in my doView method of my portlet



This is what my set method looks like



When I have this code in is when it acts wackey? I am confused now.

Thanks,

AMD
Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
I figured it out. The JSTL code was ok. For some reason it did not like it that I iniitalized the array in the form bean. As soon as I took that out it worked?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL forEach