• 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

Problem with EL returning wrong object

 
Ranch Hand
Posts: 171
1
  • 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 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
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
That is odd. Thanks for posting what you discovered.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be interesting to see the generated servlet code to see what really happened.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic