title: Action redirect is not working with list attribute after login in Struts 2
body: <p>I have the following usecase that on <code>Login</code> a <code>CustomerForm</code> should be shown and a <code>ListofCustomers</code> which is retrieved from Database should be shown.</p>
  <p>I have written the following code in Struts 2 but my <code>getCustomerList()</code> in <code>CustomerAction</code> is not getting called which is redirected during the <code>Login</code> action in <code>struts.xml</code></p>
  <p><strong><code>web.xml</code>:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!-- Struts 2 Entry Point is Filter --&gt;
  &lt;web-app id=&quot;WebApp_9&quot; version=&quot;2.4&quot; xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot;
      xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;&gt;
      &lt;display-name&gt;Struts2 Application&lt;/display-name&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&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;Login.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt; 
  </code></pre>
  <p><strong><code>struts.xml</code>:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; 
  &lt;!DOCTYPE struts PUBLIC     &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot; 
   &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;
  &lt;struts &gt;
      &lt;constant name=&quot;struts.enable.DynamicMethodInvocation&quot; value=&quot;false&quot; /&gt;
      &lt;constant name=&quot;struts.devMode&quot; value=&quot;false&quot; /&gt;
      &lt;constant name=&quot;struts.custom.i18n.resources&quot; value=&quot;ApplicationResources&quot; /&gt;
      &lt;package name=&quot;default&quot; extends=&quot;struts-default&quot; namespace=&quot;/&quot;&gt;
          &lt;interceptors&gt;
              &lt;interceptor name=&quot;mylogging&quot;
                  class=&quot;com.rahul.interceptor.MyLoggingInterceptor&quot;&gt;
              &lt;/interceptor&gt;
              &lt;interceptor-stack name=&quot;loggingStack&quot;&gt;
                  &lt;interceptor-ref name=&quot;mylogging&quot; /&gt;
                  &lt;interceptor-ref name=&quot;defaultStack&quot; /&gt;
              &lt;/interceptor-stack&gt;
          &lt;/interceptors&gt;
          &lt;action name=&quot;login&quot; class=&quot;com.rahul.action.LoginAction&quot;&gt;
          &lt;interceptor-ref name=&quot;loggingStack&quot; /&gt;
              &lt;result type=&quot;redirect&quot;&gt;/customer?method=getCustomersList&lt;/result&gt;
              &lt;result name=&quot;success&quot;&gt;Welcome.jsp&lt;/result&gt;
              &lt;result name=&quot;error&quot;&gt;Login.jsp&lt;/result&gt;
          &lt;/action&gt;
          &lt;action name=&quot;customer&quot; class=&quot;com.rahul.action.CustomerAction&quot;&gt;
          
          &lt;interceptor-ref name=&quot;loggingStack&quot; /&gt;
              &lt;result name=&quot;success&quot;&gt;SuccessCustomer.jsp&lt;/result&gt;
              &lt;result name=&quot;input&quot;&gt;Customer.jsp&lt;/result&gt;
          &lt;/action&gt;
          
      &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  <p><strong><code>login.jsp</code>:</strong></p>
  <pre><code>&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
      pageEncoding=&quot;ISO-8859-1&quot;%&gt;
  &lt;%@taglib prefix=&quot;s&quot; uri=&quot;/struts-tags&quot;%&gt;
  &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
  &lt;title&gt;Struts 2 - Login Application&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h2&gt;Struts 2 Login Application&lt;/h2&gt;
      &lt;s:actionerror /&gt;
      &lt;s:form action=&quot;login&quot; method=&quot;post&quot;&gt;
          &lt;s:textfield name=&quot;username&quot; key=&quot;label.username&quot; size=&quot;20&quot; /&gt;
          &lt;s:password name=&quot;password&quot; key=&quot;label.password&quot; size=&quot;20&quot; /&gt;
          &lt;s:submit method=&quot;execute&quot; key=&quot;label.login&quot; align=&quot;center&quot; /&gt;
      &lt;/s:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong><code>loginAction.java</code>:</strong></p>
  <pre><code>package com.rahul.action;
  
  public class LoginAction {
      private String userName;
      private String password;
  
      public String execute() {
          if (this.userName.equals(&quot;admin&quot;) &amp;&amp; this.password.equals(&quot;admin123&quot;)) {
              return &quot;success&quot;;
          } else {
              return &quot;error&quot;;
          }
      }
  
      public String getUsername() {
          return userName;
      }
  
      public void setUsername(String username) {
          this.userName = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
  }
  </code></pre>
  <p><strong><code>CustomerAction.java</code>:</strong></p>
  <pre><code>package com.rahul.action;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import com.opensymphony.xwork2.ActionSupport;
  
  public class CustomerAction extends ActionSupport {
      private String name;
      private Integer age;
      private String email;
      private String telephone;
      private List&lt;String&gt; customerList;
      private String countryName;
  
      public String getCountryName() {
          
          System.out.println(&quot;getCountryName method&quot;);
          countryName=&quot;India&quot;;
          
          return countryName;
      }
  
      public void setCountryName(String countryName) {
          this.countryName = countryName;
      }
  
      public String addCustomer() {
          return SUCCESS;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Integer getAge() {
          return age;
      }
  
      public void setAge(Integer age) {
          this.age = age;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getTelephone() {
          return telephone;
      }
  
      public void setTelephone(String telephone) {
          this.telephone = telephone;
      }
  
      public List&lt;String&gt; getCustomerList() {
          return customerList;
      }
  
      public void setCustomerList(List&lt;String&gt; customerList) {
          this.customerList = customerList;
      }
      
      
      public String getCustomersList() {
          System.out.println(&quot;Inside Customer List&quot;);
          customerList = new ArrayList&lt;String&gt;();
          customerList.add(&quot;Rahul&quot;);
          customerList.add(&quot;Saurabh&quot;);
          return SUCCESS;
      }
  }
  </code></pre>
  <p><strong><code>welcome.jsp</code>:</strong></p>
  <pre><code>&lt;%@ page contentType=&quot;text/html; charset=UTF-8&quot;%&gt;
  &lt;%@ taglib prefix=&quot;s&quot; uri=&quot;/struts-tags&quot;%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Welcome&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h2&gt;
          Howdy,
          &lt;s:property value=&quot;username&quot; /&gt;
          ...!
      &lt;/h2&gt;
      &lt;%@include file=&quot;Customer.jsp&quot;%&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong><code>Customer.jsp</code>:</strong></p>
  <pre><code>&lt;%@ page contentType=&quot;text/html; charset=UTF-8&quot;%&gt;
  &lt;%@ taglib prefix=&quot;s&quot; uri=&quot;/struts-tags&quot;%&gt;
  &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
  &lt;title&gt;Customer Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;s:form action=&quot;customer.action&quot; method=&quot;post&quot; validate=&quot;true&quot;&gt;
          &lt;s:textfield name=&quot;name&quot; key=&quot;name&quot; size=&quot;20&quot; /&gt;
          &lt;s:textfield name=&quot;age&quot; key=&quot;age&quot; size=&quot;20&quot; /&gt;
          &lt;s:textfield name=&quot;email&quot; key=&quot;email&quot; size=&quot;20&quot; /&gt;
          &lt;s:textfield name=&quot;telephone&quot; key=&quot;telephone&quot; size=&quot;20&quot; /&gt;
          &lt;s:submit method=&quot;addCustomer&quot; key=&quot;label.add.customer&quot; align=&quot;center&quot; /&gt;
  
      &lt;/s:form&gt;
  &lt;s:property value=&quot;customerList&quot; /&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>