Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5971439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:30:59+00:00 2026-05-22T20:30:59+00:00

I’m using an API that makes heavy use of Iterables (java.lang.Iterable), but I can’t

  • 0

I’m using an API that makes heavy use of Iterables (java.lang.Iterable), but I can’t use them directly on my JSP pages because JSTL tags and EL can not process them. Right now, I’m transforming each iterable to a list prior to rendering them.

What would be the cleanest and simplest approach to make it work without previous transformations?
Do newest JSTL-Jasper-EL-taglibs-etc. versions support it? Where can I found that information? I don’t find anything about it googling…

I know I can use Iterable.iterator(), but I can’t call that method inside the JSP, only in my controller class, and this is very limiting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:31:00+00:00Added an answer on May 22, 2026 at 8:31 pm

    You can implement your own JSP tags in Java, so you could write a tag that accepted an Iterable and then use that in the same way as you’d use the JSTL forEach tag.

    This documentation has an example on how to create a custom tag that iterates through an arbitrary custom object – your implementation would likely be simpler. The key is in returning EVAL_BODY_AGAIN to allow you to process the body of the tag multiple times.

    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags6.html#68297

    I haven’t tried running this, but it might be something to start with:

    public class IterableForEachTag extends BodyTagSupport {
        private static final long serialVersionUID = 1L;
        private Iterable<?> iterable = null;
        private Iterator<?> iterator = null;
        private String var = null;
    
        public int doStartTag() throws JspException {
            if (iterator == null) {
                iterator = iterable.iterator();
            }
            if (iterator.hasNext()) {
                Object element = iterator.next();
                pageContext.setAttribute(var, element);
                return (EVAL_BODY_AGAIN);
            } else
                return (SKIP_BODY);
        }
    
        public int doAfterBody() throws JspException {
            if (bodyContent != null) {
                try {
                    JspWriter out = getPreviousOut();
                    out.print(bodyContent.getString());
                    bodyContent.clearBody();
                } catch (IOException e) {
                    throw new JspException(e);
                }
            }
            if (iterator.hasNext()) {
                Object element = iterator.next();
                pageContext.setAttribute(var, element);
                return (EVAL_BODY_AGAIN);
            } else {
                return (SKIP_BODY);
            }
        }
    
        public void setIterable(Iterable i) {
            iterable = i;
            iterator = null;
        }
    
        public void setVar(String v) {
            var = v;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.