I have a string variable which is assigned with certain no. of labels. For eg, String var =”ChkBox1,ChkBox2,ChkBox3″ in a JSP.
Now, my requirement is, I have to extract the checks out of the string and store them in an array and dynamically add checkboxes(3 checkboxes as per above example) to the page by running a for loop (based on no. of elements in the array) and display them.
If the variable is later changed to String var = “ChkBox1,ChkBox2,ChkBox3,ChkBox4”, the webpage should now contain 4 checkboxes.
I am relatively new to JSP. Please help me out on how to design this logic.
PS:I already implemented the extraction of checkBoxes from string and formed an array. I need assistance on how to use a for loop to add checkboxes dynamically
1 Answer