• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LinkedHashMap Iteration problems

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a LinkedHashMap to hold all of the US States and their abbreviations.
My problem is that I want to access them from a JSP to iterate through in a drop down list but I keep getting the following error:

javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items"

Here is a snippet of the LinkedHashMap Code:



Here is a snippet of the JSP Code:



Thanks in advance for your help!

Chris Cornelius
 
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to iterate over StateMap which



is not a collection.

If it's the underlying public static map instance you want to iterate over, you must reference it, not the containing class.
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,

I have made the changes but now get this error:

javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "items" with value "${ListOfStates.stateMap}": Unable to find a value for "stateMap" in object of class "com.rxamerica.enrollment.util.StateMap" using operator "." (null)

Here are the changes:



What am I missing?

Chris
 
Bear Bibeault
Sheriff
Posts: 67748
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to study up on the EL a bit. You are trying to access a static field of the class. The EL can only access properties of classes that are established as scoped variables.

In other words. you need to provide a property accessor (getter) for the collection element.
[ December 01, 2005: Message edited by: Bear Bibeault ]
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will do, thanks!

Chris
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic