I want to populate an HTML table java spring

Discussion in 'Software' started by rajib27, Mar 16, 2010.

  1. rajib27

    rajib27

    Joined:
    Mar 15, 2010
    Messages:
    1
    Hi
    I am using java springs and jstl.I want to populate an HTML table.
    I am using the following code.It works fine but we have to create object
    each time for each row.please help How I can populate the table dynamically.


    Code:
             List<Company> companyList;
            JdbcTemplate tpl = new JdbcTemplate(ds());
                  
            srs = tpl.queryForRowSet("select CompanyName,CompanyAddress from company");
               rowCount = 0;
               Company c = new Company();
               while (srs.next()) {
                   c.setCompany_Name(srs.getString("CompanyName"));
                   c.setCompany_Address(srs.getString("CompanyAddress"));
                 rowCount++;
             }
            companyList = new LinkedList<Company>();
            companyList.add(c);
            request.setAttribute("tabvalue",companyList);
    


    HTML:
    <TABLE class="commonfieldtable" colspan="3%" align="center" width="500" bgcolor="Brown">
                <TR><TH class="commonfieldtable">CompanyName</TH><TH class="commonfieldtable">CompanyAddress</TH></TR>
                <c:forEach  var="c2" items="${tabvalue}">
                <TR bgcolor="orange"><TD class = "commonfieldtabledata">
                              <c:out value='${c2.company_Name}'/>
                               </TD>
                    <TD class = "commonfieldtabledata">
                              <c:out value='${c2.company_Address}'/>
                    </TD>
                </TR>
            </c:forEach >
                </TABLE>
     
    rajib27, Mar 16, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Z3MzMDBib2k=?=

    EAP type list doesn't populate with anything

    =?Utf-8?B?Z3MzMDBib2k=?=, Jul 11, 2005, in forum: Wireless Networking
    Replies:
    0
    Views:
    649
    =?Utf-8?B?Z3MzMDBib2k=?=
    Jul 11, 2005
  2. Joachim Krais
    Replies:
    2
    Views:
    15,104
    Andre Beck
    Nov 23, 2003
  3. John Ramsden
    Replies:
    0
    Views:
    908
    John Ramsden
    Jul 24, 2004
  4. vijendra
    Replies:
    1
    Views:
    7,908
    arpit1988
    Oct 6, 2006
  5. KiwiBrian
    Replies:
    4
    Views:
    1,434
Loading...

Share This Page