• 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

How to iterate an ArrayList of String?

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've an ArrayList that contains simple strings (not references to abject with his own properties).
A thing like this:



Into a jsp page, how i can stamp each element of the list into the page? What should i use ?
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the JSTL <c:forEach> tag. See here: http://docs.oracle.com/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/c/forEach.html

And here: http://docs.oracle.com/javaee/5/tutorial/doc/bnakc.html
 
Luk Cora
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:Use the JSTL <c:forEach> tag. See here: http://docs.oracle.com/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/c/forEach.html

And here: http://docs.oracle.com/javaee/5/tutorial/doc/bnakc.html


can i use it despite the fact that variables are passed from .java class to jsp throught struts?
In jsp i don't have any "request" object from which get attributes. I simple have an ArrayList "errors" in the java class, with setter ang getter methods, and throught struts i can access to it automatically... But using another library like core is this still possibile?
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know a lot about Struts, but I think it also uses the various Servlet/JSP scopes (page, request, session, application). So I would put the Object which has the ArrayList in the smallest possible scope (page if possible, request if not) and then the core tags should have access to it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic