This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Using ArrayLists with struts

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

I'm quite new to Struts and JSP's and I'm trying to iterate over an ArrayList to set some properties but I really can't figure out what is going wrong. I've looked up and tried several ways to do it and here's briefly what I've done in the jsp page :



Which gives me the error message :



strPostNeeds is the ArrayList I want to fill and has the same length as the array postNames. Maybe I should use the set method instead of get but I don't know I could do that. I've tried to make that using regular arrays instead but I need to have a dynamic one because I perform tests on all its values afterwards.

Any suggestion would be welcome.

Thanks in advance,

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

This line of your makes no sense. It is actually evaluated to:



As you can very well see, the servlet then tries to invoke that method on your beanObj and throws an exception.
Also, if you're using JSTL, then there's really no need to use "logic" tags.
If you can clearly state what it is you need to achieve conceptually, [copy contents of one arraylist into another?], then it'll be much easier to assist you.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code indicates a lack of understanding of how indexed properties work. It's not enough just to specify indexed="true". You must create an indexed getter in your form bean and name the properties appropriately.

My suggestion is to review this link from this forum's FAQ. Particularly look at the example code given. If you still have questions, let us know.
 
Roscoe Padsmith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for these useful links, it helps a lot. I've managed to fix my problem but then some other ones (things with hibernate and all) appear as usual. Anyway thank you again.

-- Alain
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic