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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:10:12+00:00 2026-06-18T03:10:12+00:00

There are countless examples out there for my problem, I know, but I went

  • 0

There are countless examples out there for my problem, I know, but I went through a lot of them and can’t figure out where my mistake is.

I am iterating over an ArrayList(TestSzenario). The class TestSzenario contains a String Variable called name with proper getters and setters.

Here’s my code:

<td><select name="selectSzenario" id="selectSzenario" size="1">
                <c:forEach items="<%=testszenario.getSzenariosForSummary() %>" var="szenario"> 
                    <option>${szenario.name}</option>
                </c:forEach></select></td></tr>

My Problem is, the Variable isn’t working. I alwas get ${szenario.name} for every option in the select-box. I declared the JSTL-taglib properly and since there are multiple options in the site when done i know the iteration is working. Also I looked in the HTML-sourcecode an the foreach is resolved.

HTML-output:

        <tr><td>Szenario:</td>
        <td><select name="selectSzenario" id="selectSzenario" size="1">

                    <option>${szenario.name}</option>

                    <option>${szenario.name}</option>
                </select></td></tr>

EDIT for answer 1:
Thank you, but I tried that before:

ArrayList<TestSzenario> szenarioList = testszenario.getSzenariosForSummary();
request.setAttribute("aList", szenarioList);
request.setAttribute("ts", testszenario);

<c:forEach items="${aList}" var="szenario">
<option>${szenario.name}</option>
</c:forEach></select></td></tr>

<c:forEach items="${ts.szenariosForSummary}" var="szenario">
<option>${szenario.name}</option>
</c:forEach></select></td></tr>

But in either case it doesn’t even iterate through the List, resulting in only 1 option (the List contains 2 elements).

  • 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-06-18T03:10:13+00:00Added an answer on June 18, 2026 at 3:10 am

    The <%=testszenario.getSzenariosForSummary() %> will convert the object to String using String#valueOf(Object) method and write it straight to the HTTP response. This is not what you want. Even more, you should not be mixing oldschool scriptlets with modern taglibs/EL at all.

    You need to make sure that testszenario is available to EL ${}. So, just set it as an attribute of page, request, session or application scope beforehand in some servlet like so

    request.setAttribute("testszenario", testszenario);
    

    Then you can just access it the usual way:

    <c:forEach items="${testszenario.szenariosForSummary}" var="szenario"> 
    

    See also:

    • How to avoid Java code in JSP files?
    • Our Servlets wiki page – Hello World #2 may be useful to you
    • Our EL wiki page

    Update: as to the problem of EL not being interpreted, you’ve apparently a mismatch between JSTL and container/web.xml version. Make sure that the versions are properly aligned. E.g. Servlet 3.0 container, version="3.0" in web.xml, JSTL 1.2. See also our JSTL wiki page.

    See also:

    • Our JSTL wiki page – read the section “Help! The expression language (EL, those ${} things) doesn’t work in my JSTL tags!”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll be as direct as I can concerning this problem, because there must be
This really should be easy, but I just can't work it out myself, the
I know there are countless questions about the difference between OOP and procedural, when
there are countless of examples how to wait until page fully loads after navigate
Yes, I know there are countless posts about sliding images right to left (and
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There are nice SO question and answers about this issue, but these options didn't
There are a lot of blogs saying that a hasOwnProperty check should be used
I'm using a native DLL. I'm not sure, but I think I can't use
There are a lot of topics how to read XLSX files and write to

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.