Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

problem with c:set tag

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to convert code from scripting to jstl. scripting code is running fine. But when I convert it to jstl, it gives the following ELException:
Unable to find a value for "set" in object of class "java.lang.String" using operator "."

The authorbookslist contains a map. I am retrieving the map from it and creating a set object of map and iterating through it to access keys and values. Could you please tell me where I am doing wrong.

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is here:

The items can be either a String, like you have in your code, or an iterable, like you want.

Since you aren't using EL tags, it iterates over each character in the String "authorbookslist". What you want to do is this:


Now you also try to do this:

If, like you said in the post, you expect to get a Map (as in java.util.Map) this ${autormap.set} EL will try to call the authormap.getSet() method. But Map has no such method. Fortunately for you, you don't actually have to get the entrySet in order to iterate over a map. This code should work fine:


Let me clean up your code a bit, because I saw few other problems:


I removed some unneeded c:sets to avoid confusion and to save on memory. I took out a c:out statement because it had an EL error and was not needed anyway. Them I added the changes I told you about at the top of this message.
[ August 09, 2008: Message edited by: Steve Luke ]
 
Suman Sharma
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Steve for your help. You explained it so clearly.
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic