Forums Register Login

How to use array of beans in jsp

+Pie Number of slices to send: Send
Hi everybody, I am Chaitanya, I have a jsp to which an array of beans is passed as a request attribute. I don't know how to declare that bean and how to index. This is what I have written and I am getting an error.


Please help me. Thank you all in advance.
+Pie Number of slices to send: Send
 

chaitanya karthikk wrote:I have a jsp to which an array of beans is passed as a request parameter.


Impossible. Request parameters can only be strings. You'll need to explain what you mean by this.

Do you really mean a scoped variable?
+Pie Number of slices to send: Send
Oops, I am sorry, its not a request parameter, its a request attribute actually.
+Pie Number of slices to send: Send
 

chaitanya karthikk wrote:



Can I make a couple of suggestions, firstly you are not required to use the <jsp:useBean .../> or <jsp:getProperty... /> tags if you are using EL which you seem to be using.

Next I'd change this line



In this firstly you have not declared the items attribute which is required, this must be any kind of collection or an array of beans that you want to output. Also you do not need that begin/end/step in your example because as default it begins at 0, ends at the end of the array/collection and steps by 1.



Hope this helps.

Sean
+Pie Number of slices to send: Send
Thank you Mr. Clark, I ll check whether this will work and come back soon.
+Pie Number of slices to send: Send
Hi Mr. Clark, that one worked, I have one more doubt, I want the index also, can please tell me how to get the index of each bean.

Thank you in advance. Have a nice day.
+Pie Number of slices to send: Send
Check the varStatus attribute of the forEach tag.
+Pie Number of slices to send: Send
Hi Christophe, I want to do like this

Is there any way?
+Pie Number of slices to send: Send
For now I declared another method in the bean, called setIndex(byte index)

Then I am getting the index in the jsp as ${bean.index}
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 8966 times.
Similar Threads
JSTL forEach
web container displaying jsp intead of html
JSTL choose not executing as expected
How to retain formatting when passing a String to a JSP
Converting request parameters to JSP tag-file attributes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:38:35.