• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with c:set tag

 
Suman Sharma
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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.

 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • 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 cut 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
  • Quote
  • Report post to moderator
Thank you very much Steve for your help. You explained it so clearly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic