title: Struts2 - The requested list key 'Products' could not be resolved
body: <p>I am new to Struts 2 and trying to see whether I can populate a drop down box with the list of values but still I am not able to get it working. </p>
  
  <p>Following is my Action class (Portal.java):</p>
  
  <pre><code>public class Portal extends ActionSupport {
  
      private Map Products;
      private String product;
  
      public Portal(){
         Products = new HashMap();
         Products.put("1", "Java");
         Products.put("2", "C++");
      }
  
      public Map getProducts() {  
         return Products;
      }
  
  
      public void setProducts(Map Products) {
         this.Products = Products;
      }
  
      public String getProduct() {
      return product;
      }
  
      public void setProduct(String product) {
      this.product = product;
      }  
  
      public String execute() {
         return SUCCESS;
      }
  }
  </code></pre>
  
  <p>Following is my Portal.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
  "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Portal&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Portal&lt;/h2&gt;
  &lt;s:form action="result" namespace="/"&gt;
      &lt;h4&gt;
          &lt;s:select label="Select Product"
          name="product"
          headerKey="-1"
          headerValue="Select Product"            
          list="Products"                                                     
          /&gt;
      &lt;/h4&gt;
      &lt;h4&gt;
          &lt;s:submit label="Submit" name="submitButton"  align="center" /&gt;
      &lt;/h4&gt;
  &lt;/s:form&gt;   
  </code></pre>
  
  <p>
  </p>
  
  <p>Following is my result.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org 
  /TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Results Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Portal&lt;/h1&gt; 
  &lt;h4&gt;
     Selected Product : &lt;s:property value="product"/&gt;
  &lt;/h4&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Following is my struts.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
     &lt;constant name="struts.enable.DynamicMethodInvocation" value="false" /&gt;
     &lt;constant name="struts.devMode" value="true" /&gt;
     &lt;constant name="struts.ognl.allowStaticMethodAccess" value="false" /&gt;
     &lt;package name="default" extends="struts-default" namespace="/"&gt;          
        &lt;action name="result" class="com.abc.xyz.Portal"&gt;
           &lt;result name="error"&gt;Portal.jsp&lt;/result&gt;
           &lt;result name="success"&gt;Result.jsp&lt;/result&gt;                     
        &lt;/action&gt;     
     &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  
  <p>Following is my web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee
  /web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
  
  &lt;display-name&gt;Portal&lt;/display-name&gt;
  &lt;filter&gt;
    &lt;filter-name&gt;struts2&lt;/filter-name&gt;
    &lt;filter-class&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
    &lt;filter-name&gt;struts2&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;welcome-file-list&gt;
     &lt;welcome-file&gt;Portal.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>When I execute this on Tomcat 6 server, I get following error:</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet jsp threw exception
  tag 'select', field 'list', name 'product': The requested list key 'Products' could   
  not be resolved as a collection/array/map/enumeration/iterator type. Example: 
  people or people.{name} - [unknown location]
  </code></pre>
  
  <p>But when I replace list="Products" with list="#{'1':'Java', '2':'C++'}", then it works perfectly fine .. I don't know what am I missing so that the list is not being shown.</p>
  
  <p>Please help.</p>