• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying data from a collections-type thing into a table in the JSP  RSS feed

 
Archanaa Panchal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

my first post here, so please be kind....and pardon any obvious ignorance.

i am executing a sql statement, getting back a resultSet and then converting the RS into a collections object.

i need to know how to display the various values (account id, limits, etc) in the appropriate row of a table in my jsp.

ex:

accnt_ id#1 limit#1 Notes1
..
..
accnt_id#n limit#n Notesn

to be passed to the correct cells.

thanks,
 
Ezra Simon
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It depend on your data I suppose, but you could change the ResultSet into a nested ArrayList and use it like this...

<table>
<%
ArrayList wholeDataSet = con.getListFromDB("whatever");
iter = wholeDataSet.iterator();
while (iter.hasNext()) {
ArrayList dataRow = (ArrayList) iter.next();
out.print("<tr>");
out.print("<td>"+(String)row.get(1)+"</td>");
out.print("<td>"+(String)row.get(2)+"</td>");
out.print("<td>"+(String)row.get(3)+"</td>");
//if variable amount of data use a loop here
out.print("</tr>");
%>
</table>

I would like to see some other alternatives as well.

Jon

------------------
Projects on GoodNoodles
http://www.goodnoodles.com/
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!