2 Replies - 1955 Views - Last Post: 17 March 2010 - 04:56 AM

#1 rajib27  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-March 10

I want to display database values in a table(HTML)(java springs)

Posted 14 March 2010 - 11:41 PM

Hi I am using java springs,and jstl. I want to display database values in a table(HTML).
I have tried as follows it is fine but each time i have to create an Object for each row.
You can see below I have created two object c1 and c2 for two rows;
Help me to solve my problem.

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



Edited by Dogstopper: :code:

This post has been edited by Dogstopper: 15 March 2010 - 05:40 AM


Is This A Good Question/Topic? 0
  • +

Replies To: I want to display database values in a table(HTML)(java springs)

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,023
  • Joined: 15-July 08

Re: I want to display database values in a table(HTML)(java springs)

Posted 15 March 2010 - 05:42 AM

This is JavaEE, so I think it will get the best attention in the JavaEE subforum.
Was This Post Helpful? 0
  • +
  • -

#3 chandraoops  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 17-March 10

Re: I want to display database values in a table(HTML)(java springs)

Posted 17 March 2010 - 04:56 AM

http://www.crazysqui...tl-forEach.jspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1