wood burning stoves 2.0*
The moose likes JSP and the fly likes Help accessing data in a List of Maps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Help accessing data in a List of Maps " Watch "Help accessing data in a List of Maps " New topic
Author

Help accessing data in a List of Maps

Liana Daughtry
Greenhorn

Joined: Mar 27, 2010
Posts: 13
I have been working on something for hours and I hope someone can help. I have a List of Map objects that I am trying to access in my JSP. I am using Struts. The List defined in my Action class looks like this:

List<Map<String, String>> errmsgArr
request.setAttribute("errmsgArr", errmsgArr);

Nothing I have tried is working. I wanted to populate a table, but I have finally given up and stripped the code down to what follows. I just wanted to see if I could access the table, so I coded the following in my JSP:



According to different examples I found the code should work, but my HTML page shows up blank. What am I missing?
By the way, I displayed the data in the table before I issued the retun, so I know there is data in the table.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

The HTML is blank, or the page is blank? These are not the same things. Is anything being sent to the browser?

Have you used fn:length() to check the size of the list and maps when they get to the JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Liana Daughtry
Greenhorn

Joined: Mar 27, 2010
Posts: 13
Okay, I found the error of my ways. I displayed the contents of the list in a class called by my action (as opposed to displaying right before issuing the return). For whatever reason I returned null back to the action instead of the List. Now that the mystery is solved, I am wondering how to accomplish what I really need to accomplish. I get the following results when I execute the jsp in my original question:

messageId 02c54758b
claim 123456
code 040
node Blue
id TEST999999999
messageId 02c54758c
claim 123789
code 040
node Blue
id TEST99999999

The keys can vary from request to request because the user can select which fields to display on the report. So, I would like the column headers to be based on the the key fields and the rows to be based on the values. The output should look like:

messageId claim code node id
02c54758b 123456 040 Blue TEST999999999
02c54758c 123789 040 Blue TEST999999999

Any advice on the best way to make the above happen?
Liana Daughtry
Greenhorn

Joined: Mar 27, 2010
Posts: 13
Someone sent me the solution I was looking for, so I am posting it just in case someone else has the same question.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help accessing data in a List of Maps
 
Similar Threads
JSTL printing issue
Websphere 6 not recognizing c:forEach
A cleaner way to display LinkedHashMap/ArrayList
forEach nested loop
Display of hashmap values using jstl