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 78433
In Process

The Archive Base Latest Questions

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

I’ve experienced rather strange behavior of JSTL forEach tag. I have some bean called

  • 0

I’ve experienced rather strange behavior of JSTL forEach tag.

I have some bean called SessionBean:

public class SessionBean {   private Collection<MyObject> objects;   public Collection<MyObject> getObjects() {return objects;}   ... } 

And a simple JSP page like that:

<%@page contentType='text/html'%> <%@page pageEncoding='UTF-8'%> <%@taglib prefix='f' uri='http://java.sun.com/jsf/core'%> <%@taglib prefix='h' uri='http://java.sun.com/jsf/html'%> <%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %> <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> <html> <body>     <f:view>         <h:form>             <c:forEach var='myObject' items='#{SessionBean.objects}'>                 <h:outputText value='#{myObject}' /> <br />             </c:forEach>         </h:form>     </f:view> </body> 

And, it doesn’t work. Exeption thrown is

 javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied 'items' in <forEach>         at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:255)         at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:219)    .... 

Why?
And then I change items='#{SessionBean.objects}' to items='${SessionBean.objects}', and there’s no exception. Except for MyObjects aren’t printed.

Then, I make the same change to <h:outputText value='#{myObject}' />, and it’s invalid value for this attribute.

Finally, replacing JSF outputText tag with just ${myObject} works as expected.

Could somebody explain, what happens here on each phase, please?

U: SessionBean is managed by JSF, and surely was created, for it performs some actions in the header.

RESOLUTION: The problem proved to be due to incompatibility between JSTL and JSF in J2EE 1.4. Switching to J2EE 5 made the first variant work just fine.

Thanks!

  • 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. 2026-05-10T20:59:12+00:00Added an answer on May 10, 2026 at 8:59 pm

    This article explains the difference between the unified EL and the EL. Here is a snippet

    Evaluation of EL

    Evaluation of EL is categorized as immediate evaluation and deferred evaluation. Immediate evaluation means a JSP page evaluates the expression when the page is rendered. With immediate evaluation, all values are always read-only. JSP EL expressions take the form of ${imExpr}. JSP expressions are evaluated immediately.

    Deferred evaluation means that the technology using the unified EL takes over the responsibility of evaluating the expression from the JSP engine and evaluates the expression at the appropriate time during the page lifecycle. The EL takes control from the JSP container to evaluate the expression at the appropriate time. JSF EL expressions take the form of #{defExpr}. JSF expressions work in this way.

    The following example shows a JSF inputText tag, which represents a text field component into which a user enters a value. The inputText tag’s value attribute references an expression that points to the name property of the book bean.

    <h:inputText id='name' value='#{student.name}'/> 

    For an initial request of the page containing this tag, the JSF implementation evaluates the #{student.name} expression during the ‘render response’ phase of the lifecycle. During this phase, the expression merely accesses the value of quantity from the book bean, as is done in immediate evaluation.

    For a postback, the implementation evaluates the expression during the ‘apply request values,’ ‘process validations,’ and ‘update model’ phases, during which the value is retrieved from the request, validated, and propagated to the book bean.

    I am wondering if the problem is from the fact that an instance of SessionBean was not created?

    Try this:

    <jsp:useBean class='packagename.SessionBean' id='sb'/> <c:forEach var='myObject' items='${sb.objects}'>             <h:outputText value='${myObject}' /> <br /> </c:forEach> 

    [Update] I wonder if this article might help then. It explains how the two EL’s work together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.