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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:59:04+00:00 2026-06-15T00:59:04+00:00

I am trying to iterate over a list and trying to print the value

  • 0

I am trying to iterate over a list and trying to print the value as:

<jsp:useBean class="com.lftechnology.db.EmployeeDaoImpl" id="empImpl"></jsp:useBean>
<jsp:useBean class="com.lftechnology.employee.Employee" id="employee"></jsp:useBean>

<%
List<com.lftechnology.employee.Employee> empList = null; 
empList = empImpl.getAllEmployee();
out.println(empList.size());
%>


<c:forEach items="${empList}" var="element"> 
  <tr>
    <td>${element.name}</td>
    <td><c:out value="${element.name}" /></td>
     </tr>
</c:forEach>

However, only the size of the list is printed not the name as defined inside jstl. Any help? I want to print the all the attributes of employee object.

  • 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-15T00:59:05+00:00Added an answer on June 15, 2026 at 12:59 am

    Why do you use the scriptlet at all? Something like this should work (I could not test it):

    <jsp:useBean class="com.lftechnology.db.EmployeeDaoImpl" id="empImpl"></jsp:useBean>
    
    <c:forEach items="${empImpl.allEmployee}" var="element"> 
      <tr>
        <td>${element.name}</td>
        <td><c:out value="${element.name}" /></td>
      </tr>
    </c:forEach>
    

    Some background

    Just declaring a variable in a scriptlet does not automatically make it available to the JSTL runtime. In fact JSTL works on the pageContext injected into each JSP at runtime by the container. So if you really need to declare a variable in a scriptlet and want to make it available to JSTL you have to do this explicitly:

    <%
    List<String> stuff = new ArrayList<String>();
    request.setAttribute("mystuff", stuff);
    %>
    
    <c:out value="${mystuff" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to iterate over a value list and convert it into a string.
I've been trying to figure out how to iterate over the list of columns
Im trying to iterate over a nestled dict list. The first level works fine.
I am trying to iterate over list of controls to determine which checkboxes are
I'm trying to iterate over a list of strings in MATLAB. The problem is
Is it possible to iterate over a list of functions in MATLAB? I'm trying
I am currently trying to iterate over a list which will generate a <div>(...)</div>
Hi I am trying to iterate over a list of custom buttons which I
I am trying to iterate over a list of parameters, in a grails controller.
I am trying to iterate over a backbone collection object and print one of

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.