File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with EL returning wrong object

 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to set up a simple JSP page on Tomcat 5.5.4 using JSTL-standards-1.1.2. Here is the problem I am having. I think it is a bug in commons-el.

My session scope contains an object (paginator) which has a property "itemsforpage" which returns a List:



I am trying to iterate over this list like this:



When I try to access the page, I am getting an exception:



which says that it doesn't know how to iterate over the items I specified.
${paginator.itemsforpage}. I did some debugging and I found that the object it is dealing with is actually of type Paginator (not List)!!

It is as if I had items="${paginator}" instead of items="${paginator.itemsforpage}". However, the paginator.getItemsforpage() method is getting called.

1) Why is commons-el evaluating this expression to the wrong object? I think this is a bug.

2) Why is it using that commons-el expression evaluator (comes with Tomcat) instead of JSTL 1.1? Can I force it to use the real JSTL standards.jar?

Thanks
Geoffrey
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PS I tried this with Tomcat 5.0.30 and had the same problem.
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer my own question, in case anyone comes here with the same problem..

I found the problem. It was not the <c:forEach> tag. It was something in a completely different area of the page. I had this in my JSP:



which is wrong because "paginator" is not a collection. I should have had:



with this it works fine.

BUT: The real problem is that the error message is extremely misleading!! The problem had nothing to do with <c:forEach>, yet the error message indicated that it did!! This cost me 6 hours of time!!!

Someone should really fix this misleading error message!!!

Grr...
Geoffrey
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is odd. Thanks for posting what you discovered.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be interesting to see the generated servlet code to see what really happened.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic