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

  • Home
  • SEARCH
  • 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 8750679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:54:32+00:00 2026-06-13T12:54:32+00:00

Possible Duplicate: Java add all table data into list +——–+——-+—–+ | Name |number |qty

  • 0

Possible Duplicate:
Java add all table data into list

+--------+-------+-----+
|  Name  |number |qty  |
+--------+-------+-----+
|   ab   |   5   |  7  |
+--------+-------+-----+ 
|   cd   |   1   |  6  |
+--------+-------+-----+ 
|   ef   |   0   |  9  |
+--------+-------+-----+ 
|   gh   |   8   |  2  |
+--------+-------+-----+ 

I add all data in Product to Array List as shown below

public List<Product> search(){
    List<Product> products = new ArrayList<Product>();
    ResultSet rs = DAO.fetch("SELECT * FROM Products");
    while (rs.next()) {
        product = new Product();
        product.setNumber(rs.getString("ProductNumber"));
        product.setName(rs.getString("ProductName"));
        product.setQty(rs.getString("ProductQty"));
        products.add(product);
    }
    return products;
}

How do i print all names in my jsp by using this?

  • 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-13T12:54:33+00:00Added an answer on June 13, 2026 at 12:54 pm

    You can pass the list by saying the below statement in the controller

    List <Product> products = dao.search();
    request.setAttribute("Products", products);
    

    And, in your JSP you can use the following code (I am considering you know how to use include JSTL Libraries on your JSP Page).

    For using the JSTL Core library, you will need to add the below line in your JSP

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    

    And then you can display the traverse the passed list to display all the products.

    <table>
       <tr>
         <th>Name</th>
         <th>Number</th>
         <th>Quantity</th>
       </tr>
     <c:forEach items="${Products}" var="product">
        <tr>
          <td><c:out value="${product.name}" /></td>
          <td><c:out value="${product.number}" /></td>
          <td><c:out value="${product.qty}" /></td>
        </tr>
      </c:forEach>
    </table>
    

    Hope it helps.

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

Sidebar

Related Questions

Possible Duplicate: Add leading zeroes to number in Java? I want to add prefix
Possible Duplicate: How to add days to a date in Java I need to
Possible Duplicate: File to byte[] in Java I want to read data from file
Possible Duplicate: Java Generics: Cannot cast List<SubClass> to List<SuperClass>? I want to create function
Possible Duplicate: Java random always returns the same number when I set the seed?
Possible Duplicate: add values to enum Why enums in Java cannot inherit from other
Possible Duplicate: Java - Distinct List of Objects i have a sorted array of
Possible Duplicate: Sorting a collection of objects How to sort the list in java
Possible Duplicate: Is List<Dog> a subclass of List<Animal> ? Why aren't Java's generics implicitly
Possible Duplicate: Is List<Dog> a subclass of List<Animal>? Why aren't Java's generics implicitly polymorphic?

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.