0

enter image description here

Here, I am trying to print 10 labels using getter methods there are 10 getter methods in my bean class named as getLabel1(),getLabel2().......getLabel10(). instead of writing these 10 getter methods, I am using here foreach loop in jstl for each iteration i am combining the iteration value to getMethod name. I am also trying like this

${labelsBean.getLabel+""+${i}+""+()} and ${labelsBean.getLabel+${i}+()} and ${labelsBean.getLabel${i}()} and ${labels.label[i]}

not working all above can you please give me a suggestion to solve this error

shmosel
  • 49,289
  • 6
  • 73
  • 138
  • 1
    It's not clear what you want to achieve? Do you want to combine values of 10 fields into single string and display in your JSP? You don't need to access the getter method directly in jstl. use your field name instead like `labelsBean.label1` – VPK Jan 06 '17 at 05:31
  • Please don't tag spam. – shmosel Jan 06 '17 at 05:35
  • [Please don't post your code as an image.](//meta.stackoverflow.com/q/285551) – 4castle Jan 06 '17 at 05:35
  • Refer this http://stackoverflow.com/questions/160970/how-do-i-invoke-a-java-method-when-given-the-method-name-as-a-string – RaR Jan 06 '17 at 05:35
  • This question has a bad smell. You should probably store your labels in a list instead of having a separate method for each. – shmosel Jan 06 '17 at 05:37

0 Answers0