wood burning stoves 2.0*
The moose likes Websphere and the fly likes Display Data Records in Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Display Data Records in Table" Watch "Display Data Records in Table" New topic
Author

Display Data Records in Table

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1390
How can I use a resultset from a remote connection I get with a bean and display this on a JSP table? I am puting the resultset into an array and can put this into a list but I really need it in a table.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is no such thing as a JSP table.

I would avoid working directly with the database connection and/or connection from within your JSP.

A common way to do this is to write a bean that represents a single row in your table.
Loop through the result set, creating one row bean for each row in the resultset and add it to a List (java.util.ArrayList is commonly used for this). Then bind the list of row beans to request scope and forward to the JSP. From within the JSP you'll be able to use JSTL/EL to loop through the list of rowBeans to present your data as an HTML table.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1390
I the list of components for my JSP I have Dynamic Table. Could and how would I use this if my data is in a multi dimetenional array?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You could use an ArrayList of ArrayLists.

This could be iterated over with a nested set of c:forEach tags
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1390
Could you please give me an example of what the code in the JSP should look like? This is the code generated when I add the Dynamic Table to the page. My array is called faiArray.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Originally posted by Steve Dyke:
[QBwhen I add the Dynamic Table[/QB]


What is a "Dynaimc Table"? Is it a 3rd-party tag library or some such? We're not mind readers.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1390
This is the lib I import when adding a new JSP to my project

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

In the list of components that I can choose from Dynamic Table is one of them. I wished I was more knowledgable in this area so my posts would not be so sketchy.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Dynamic Table is not a JSTL "component".

In the list of components that I can choose from


What list? From where? In an IDE?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

When you say "Dynamic Table' do you just mean that you don't know the number and names of the columns in the resultsets returned from your database query or is Dynamic Table the brand name of some third party library that you're using?

There is nothing in JSTL called Dynamic Table.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1390
I am using Websphere Development Studio. The term Dynamic Table is the name on the component listed in the set of tools. I an earlier post it was suggested to use ArrayList and then a nested set of c:forEach tags. Can you tell me how to do the nesting so the contents of list one is in column one and list two is in column two etc?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

We have an IBM Web sphere forum where you are more likely to find some help with their proprietary objects.
I'll move this discussion over there.

If, you can get help getting the data into the nested lists or arrays but still need help with the JSTL tags, either ask the moderator there to move it back here or start a new topic here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display Data Records in Table
 
Similar Threads
how can i resultset data to text file in a table format
Result Set display in JSP
How to Populate a Table from ResultSet
Using div tag in HTML Table Header
displaying database records rowwise in the table