Can anyone help me to store my result set into another object so that I can display it on my jsp page in a table. I can get output of my resultSet from a System.out.println(rs.getString(i)) stance. I tried storing each row in a vector and then each row of vectors in a vector....to no avail. can anyone help me?

What do you mena, to no avail? It definately should work. Vectors may not be the best choice (at least from an efficiency standpoint), but it should work. It would probably be helpful to show the code and provide the complete detils to any error you may ahve gotten.

Post error message so we can know what type of error you are receiving.

If i understand correctly, then for example you can do like this

.
.
.
 
Vector<Map> vs = [B]new[/B] Vector<Map>();
[B]while[/B](rs.next())
{
Map<String,String> v = [B]new[/B] HashMap<String,String>();
v.put("My field 1",rs.getString("My field 1"));
v.put("My field 2",rs.getString("My field 2"));
v.put("My field 3",rs.getString("My field 3"));
vs.add(v);
}
.
.
.
.
[B]for[/B](Map v : vs)
{
System.[I]out[/I].println(v.get("My field 1") + " " + v.get("My field 2") + " " + v.get("My field 3") + " ");
}

Hi,

the best possible way in my view is to create a VO.
A VO containes getter-setter for all the fields which
you want to display or store.

then
while(rs.next())
{
// Initialize a VO
//put all the columns in the VO
// put the VO in any collection ...i wud go for ArrayList
}
then put the object collection object in the request attribute and
then retireve that object in JSP and display

cheers,

Something like this would be an appropriate way to output the data from that Collection.

<c:forEach items="${dataCollection}" var="record">
  <tr>
     <td><c:out value="${record.val}"/></td>
  </tr>
</c:forEach>

And indeed use an ArrayList instead of a Vector (or a HashSet if ordering isn't important, it's even faster).
ArrayList (I have personally tested this) is something like 10 times faster than Vector for most purposes.

This article has been dead for over six months. Start a new discussion instead.