Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > I want to populate an HTML table java spring

Reply
Thread Tools

I want to populate an HTML table java spring

 
 
rajib27 rajib27 is offline
Junior Member
Join Date: Mar 2010
Posts: 1
 
      03-16-2010
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 Code:
<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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spring Python 0.8.0 has been released/Spring Python goes green Goldfish Python 1 11-06-2008 06:12 PM
differences between Spring WebFlow,Spring MVC,and String Portlet MVC? rmn190 Java 2 01-10-2008 02:27 AM
Populate oracle table with values in CSV using Java csv java Java 6 10-15-2006 05:41 AM
How to populate HTML table from local text file. alex Javascript 10 03-31-2005 10:28 PM
Populate a popup window with clickable records from an Access DB and upon clicking, populate a selectbox on the original webpage with the clicked record Enjoy Life ASP General 2 02-23-2005 10:48 PM



Advertisments