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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:30:44+00:00 2026-06-06T22:30:44+00:00

I have an HTML table in my jsp page. This conains text fields and

  • 0

I have an HTML table in my jsp page. This conains text fields and a drop down box.
From my servlet, I want to pass an arraylist of Strings called myData.

Therefore I attempt to use foreach to transfer the data to my html table:

<table border="1" >
  <c:forEach items="${myData}" var="result">
  <tr>
    <td><input name="from0" type="text" value="${result}"/></td>
  </tr>

  <tr>
     <td>
    <select name="from8" id="from8" value="${result}">
       <option>Yes</option>
       <option>No</option>
    </select>
      </td>
  </tr>
  </c:forEach>
</table>

The arraylist is a simple arraylist of strings:

ArrayList<String> output = new ArrayList<String>();
//populate arraylist with values here

//forward the arraylist of strings
request.setAttribute("myData ", output);
request.getRequestDispatcher("Home.jsp").forward(request, response);

Unfortunately the output generates multiple tables whose values all correspond to each element in my arraylist.

  • 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-06T22:30:45+00:00Added an answer on June 6, 2026 at 10:30 pm

    Based on you given information, I tried to recover your situation. Honestly I couldn’t do that. Here is my try for recovering:

    <%
        ArrayList output = new ArrayList();
        output.add("Yes");
        output.add("No");
        request.setAttribute("myData", output);
    %>
    <table border="1">
      <c:set var="counterVar" value="0"/> //added because form field names and ids -in genral- must be unique.
      <c:forEach items="${myData}" var="result">
      <tr>
        <td><input name='from<c:out value="${counterVar}"/>_text' type="text" value='<c:out value="${result}"/>'></td>
      </tr>
    
      <tr>
         <td>
        <select name='from<c:out value="${counterVar}"/>_select' id='from<c:out value="${counterVar}"/>' value='<c:out value="${result}"/>'>
           <option value="Yes">Yes</option>
           <option value="No">No</option>
        </select>
          </td>
      </tr>
      <c:set var="counterVar" value="${counterVar + 1}"/>
      </c:forEach>
    </table>
    

    This generates a good looking table. Can you provide an example link with your problem?

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

Sidebar

Related Questions

My problem is I have one html table in jsp page .And i applied
I have a jsp page in which there is a html table. The contents
Have JSP page with dynamically generated HTML table with unknown number of rows. Have
I have the following jsp file <%@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1%> <%@ page
I have a html table like this: Invoice# Due Date Balance Select 12345 12/25/2011
I have this html table: <table class=table-all> <tbody> <tr> <td>BISFENOLO</td> <td>Bisfenolo-AF 10/10</td> <td class=right>€
I have the following HTML in a JSP file: <div class=custList> <table class=dataGrid> <c:forEach
This could be a repeat question, I apologize. I have a jsp page in
Hello i have a JSP page that contain a form, i want to validate
I have a jsp page in which rows are created dynamically to a table

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.