File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes showing values in table on basis of column header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "showing values in table on basis of column header " Watch "showing values in table on basis of column header " New topic

showing values in table on basis of column header

Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113


I have a technical problem related to java html and jsp where I have to show a table. Table is such that it has headers on top of table and when page loads I should load the data in table depending on corresponding column header.

To be more specific- I would like to call a function on every "square-box" of column/rows and call a function with column header name as parameter in java which returns me the data and I need to show it in table.

Is it possible to do in jsp ?


Tanu Gulati
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 445

Not clear what you are trying to achieve now.

The data to be displayed is probably generated dynamically and in that case you could take care of that in server side Java code. Now why would you want to have a separate Server call (I assume) each time a table column is rendered?

I feel you should have the logic for generation of the table headers/rows/columns in your server side code and JSP should be used for dynamic display purposes.

Could you please elaborate your requirement a little?

Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
I'm guessing the data structure you are wanting is List<Map<String, Object>>
ie a List of Maps, each entry in the list representing one 'row' of the table, and the map being the values to display.
The key to the map being the 'column heading', and the value, the value to display in that column.
Its a fairly standard pattern for writing a 'generic' table that can display whatever you configure it to.

Personally I prefer defining the columns rather than having them be dynamic, and using a java bean with attributes rather than entries in a map, but it does work.
It goes something like this (untested)

I agree. Here's the link:
subject: showing values in table on basis of column header
It's not a secret anymore!