Vector profileList = new ArrayList();
profileList = DAO.getProfiles();
for (int i=0; i<profileList.size(); i++)
SomeBean myBean = profileList.elementAt(i);
Now I know this would be easier if I used the forEach loop of JSTL... The problem is... I don't know how I would actually fill in the value it iterates...
<c:forEach var="profiles" items="whatDoIPutHere???">
//print the username attribute in the bean
Your beans should be populated from within a servlet or Model bean.
Originally posted by Timothy Sam:
Ok... Here's the idea... I have a JSP page that has a drop down menu... Or a Drop down listbox if that's what to call it... I want the listbox populated from my database and usually... I would use a DAO, put the results in a Vector, and loop through that Vector and put each element in a bean... Is there any better way of doing this? I would appreciate some code samples. Thanks!
Although, Ben's answer is quite complete and straight. But I would like to be a bit more specific to what you are doing. Dont loop through that Vector. you should rather loop through your ResultSet object, place values in your bean/TO/VO property, then add that bean to your collection, in your case Vector.