• 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

Accessing Object Methods In An ArrayList Using c:forEach?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is there a way to access the methods of an object within an ArrayList in a JSP without scripting? For instance using java like below i could call variable get methods in order to find out details about a basket item.



Assuming i'm using a bean that will return the ArrayList 'basketItems', can i set different var properties of the c:forEach tag (assuming c:forEach will be able to perform the operation)?

Any advice would be greatly appreciated (as always!)
 
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
To tell you the truth I couldn't make out what you are asking, but iterating over a list of beans is completely straight-forward.

Something like:



The listed items must be true JavaBeans, and you can only access properties of the bean, not general methods.
[ March 28, 2006: Message edited by: Bear Bibeault ]
 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for not explaining very well!

But thank you anyway....what you have suggested solved my problem, never imagined it would be so straightforward.
 
Bear Bibeault
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
The combination of the JSTL and the EL is a powerful tool for simplifying JSP pages dramatically. The key is making sure that the data sent to the JSP pages conforms to EL-friendly structures. Lists (and other collections), arrays, Maps and JavaBeans make for straight-forward and easy access.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic