Recently I was using Struts v1.x and I needed to display a select list. The information about how to use the html:optionsCollection tag was sketchy. I was able to get the tag working this way:

On the JSP page, I added this inside the html:form tag:

<html:select property="selectedEquipment">
  <html:optionsCollection property="equipment" label="name" value="id"/>

Then I create a Java class called SelectOption like this:

package com.codebits.struts;

public class SelectOption {

    String id;
    String name;

    SelectOption() {

    SelectOption(final String _id, final String _name) {

    public String getId() {
        return id;

    public void setId(String id) { = id;

    public String getName() {
        return name;

    public void setName(String name) { = name;

Next I created an ActionForm bean:

package com.codebits.struts;

public class AddForm extends ActionForm {

    private Integer           selectedEquipment = null;

    private List              equipment         = new ArrayList();

    public Integer getSelectedEquipment() {
        return selectedEquipment;

    public void setSelectedEquipment(Integer selectedEquipment) {
        this.selectedEquipment = selectedEquipment;

    public List getEquipment() {
        return equipment;

    public void addEquipment(final String equipmentId, final String emtEquipmentId) { SelectOption(equipmentId, emtEquipmentId));

    public void setEquipment(List equipment) { = equipment;


And finally, in my action class, I prepopulated the ActionForm bean:

  AddForm addForm = (AddForm)form;
  addForm.addEquipment("1", "AAA");
  addForm.addEquipment("2", "BBBB");