File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes problem with c:set tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem with c:set tag" Watch "problem with c:set tag" New topic

problem with c:set tag

Suman Sharma
Ranch Hand

Joined: May 16, 2005
Posts: 72
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

Joined: Jan 28, 2003
Posts: 4181

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

Joined: May 16, 2005
Posts: 72
Thank you very much Steve for your help. You explained it so clearly.
I agree. Here's the link:
subject: problem with c:set tag
It's not a secret anymore!