• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Possible to iterate through a Set?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone!

I've just started learning Struts and this is my current problem:
I have a java.util.Set which is saved in the current session and I'm trying to use Struts for checking if it's not empty and in that case iterating through it (from a JSP). This is the beginning of that code:


When I try stepping through the code, the logic:notEmpty tag is handled just fine, but when I get to the logic:iterate tag I get this exception:

javax.servlet.jsp.JspException: Cannot create iterator for this collection

Does anyone know if it's possible to iterate through a Set using Struts in any way?

I could always make it work by writing a scriptlet and iterate through it the regular Java way, but I'm trying to use as much Struts as possible since I'm doing a thesis where one of the issues is what the benefits of Struts are. (And besides, I've read that using scriptlets is "bad style" nowadays.)

So if anybody knows a Struts solution to this, I'd be very grateful!

Thanks in advance!

/Ylva
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The logic:iterate is supposed to work over any object that has java.util.Collection as an interface or super-interface. Since java.util.Set has java.util.Collection as a super-interface, yours should work. Which version of Struts are you using?
 
Ylva Degerfeldt
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts was bundled with NetBeans 5.5.1 but it seems like it's version 1.2 (according to the DTD used). Is it possible that there is a newer version of Struts (that is not Struts 2), where this works?

/Ylva
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic