wood burning stoves*
The moose likes Struts and the fly likes How to break from the struts logic:iterate tag ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to break from the struts logic:iterate tag ?" Watch "How to break from the struts logic:iterate tag ?" New topic

How to break from the struts logic:iterate tag ?

pratibha patel

Joined: Feb 22, 2007
Posts: 15
Hello All,

In JSP I am using logic:iterate tag to iterate my collection. In scriptlet I have if and else statements, when certain condition met, I want to break form the loop.
something like this example:

Now I want to break after else conditon from iterate loop. So if I put break, it throws an exception says Code is unreachable.

Is there any way to break from iterate tag ?

Please do the needful.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60810

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
getshijos joseph

Joined: May 28, 2010
Posts: 5
As far as I know , struts doesn't support break from iterate. It expects a collection to be populated by Action class and view will only render the prepopulated collection. All those logic to filter the collection should be done within the action class.

Wanna recharge
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

You can use logic:equal/logic:notEqual tags inside logic:iterate tag
It is sorta covered in the JavaRanch Style Guide.
subject: How to break from the struts logic:iterate tag ?
Similar Threads
passing values from struts2 form to javascript
MultiDimenaional Array sort
Returning A List Of Variables From A Folder Of Documents And Returning Them Into A New Document
<html:link> problem
Data display in table usinf logic:iterate tag