Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between [c:forEach] and [logic:iterate]

 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen some posts that discussed about <logic:iterate> tag. Seems to me that, this tag is going to loop through a list or collection and access it one by one. I have not used it before, but it seems provide similar functions as <c:forEach>.

Could anyone tell me the major difference between the <c:forEach> tag and <logic:iterate> tag?

Nick
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSTL c:forEach tag is standard and is often recommended over Struts' logic:iterate.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note: - Many of the features in this taglib are also available in the JavaServer Pages Standard Tag Library (JSTL). The Struts team encourages the use of the standard tags over the Struts specific tags when possible.

The "struts-logic" tag library contains tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lasse,

If it is recommended to use JSTL core library, why I saw some many people try using Struts' <logic> tag, instead of <c> tag?

That's really interesting.

And that's why I wanna know, is that becos something that <logic> can do, but <c> cant, so, people try to use <logic>.

Nick
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Cheung:
If it is recommended to use JSTL core library, why I saw some many people try using Struts' <logic> tag, instead of <c> tag?

Perhaps because the vast majority of application servers in production today don't have JSTL support, yet.
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lasse,

Perhaps because the vast majority of application servers in production today don't have JSTL support, yet.


You can support JSTL as well as Struts tag-lib.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by surasak lee:
You can support JSTL as well as Struts tag-lib.

Yes, if you're using a recent-enough application server or if you download and "install" a JSTL implementation. What I meant was that JSTL taglibs are not available out-of-the-box on most application servers in production today (for example, Tomcat 4.1 represents a big share of what's out there and plain vanilla Tomcat 4.1 does not include the JSTL taglibs...).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic