title: Populating drop down with values in bean object Struts
body: <p>I am having a Struts2 app where I am using a dropdown. I populated this dropdown with userId and userName from Users bean as below</p>
  
  <pre><code>public class DropDown extends ActionSupport{
      private List arrUserDetails = new ArrayList&lt;Users&gt;();
  
      public DropDown()
      {
          Users objUsers = new Users();
          objUsers.setUserId("101");
          objUsers.setUserName("User1");
  
          arrUserDetails.add(objUsers);
  
          objUsers.setUserId("102");
          objUsers.setUserName("User2");
  
          arrUserDetails.add(objUsers);
  
          objUsers.setUserId("103");
          objUsers.setUserName("User3");
  
          arrUserDetails.add(objUsers);
      }
  
      public String execute(){
          return SUCCESS;
      }
  
      public List getArrUserDetails() {
          return arrUserDetails;
      }
  
  
      public void setArrUserDetails(List arrUserDetails) {
          this.arrUserDetails = arrUserDetails;
      }
  }
  </code></pre>
  
  <p>The Users bean is as Given Below</p>
  
  <p><strong>Users.java</strong></p>
  
  <pre><code>public class Users
  {
      private String userId;
      private String userName;
  
      public String getUserId() {
          return userId;
      }
      public void setUserId(String userId) {
          this.userId = userId;
      }
      public String getUserName() {
          return userName;
      }
      public void setUserName(String userName) {
          this.userName = userName;
      }
  }
  </code></pre>
  
  <p>I wrote a Code in JSP using Struts2 tag lib to Iterate through the List 
  so that the drop down  gets populated</p>
  
  <pre><code>&lt;s:select label="UserList" list="arrUserDetails" name="yourSearchEngine" /&gt;
  </code></pre>
  
  <p>But it is displaying memory location in drop down rather than UserName for Option and UserId as Value</p>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>&lt;select name=""&gt; 
    &lt;option value="101"&gt;User1&lt;/option&gt;
    &lt;option value="102"&gt;User2&lt;/option&gt;
    &lt;option value="103"&gt;User3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>