There are several ways you can do this.
What you have done is made one arraylist with all the fields serially put into it.
You probably want to have each row as some kind of object and then put these
objects into a list.

You could your the jstl Result class which puts your result set into an
object where there results are an array of sortedmaps. The jstl documentation
has examples for using this with c:foreach.

You could make each row an array and add the array to the arraylist.

You could make each row a map and add the map to the arraylist.

You could use the apache.commons.beanutils library's RowSetDynaClass.

You could use apache.commons.dbutils which has a whole bunch of handlers for
making things like a list of beans, a list of maps or a list of arrays.

Finally if you want to display the results in a table without doing all the dirty work
you should consider displaytag.  http://displaytag.sourceforge.net/11/


mas


Vaylee Mckenzie-Daniels (VA) wrote:
Hi

I have to display results in  jsp that is retrieves from the database.
After I retrieve the results, I place the it in an arraylist.
But I am a bit confused on how to retrieve an entire row, because I
add each field to the arraylist.

Eg. String name = rs.getString(1); //value = myname
Arraylist.add(name);

String surname = rs.getString(2); //value=mysurname
Arraylist.add(surname);

When I retrieve the results they are displayed:

Myname
Myname
Anothername
Anothersurname
AThirdName
AThirdSurname


I am using <c:foreach /> in the jsp page.
Please help!



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to