title: Struts2: can't call action before rendering index.jsp
body: <p>I've searched for this all over SO, but didn't find a similar situation with the same symptoms. I'm using Sruts2 and trying to invoke an action before rendering the main page of my application (index.jsp). I truly believe that this action is not being called, because I have a <code>System.out.println()</code> (for debugging purposes) in the beginning of the <code>execute()</code> method of the action that is not being printed. Indeed index.jsp is being presented (because it is the default page), but the part that is related to the action is not being run. In conclusion, I think that the problem may reside in the <code>struts.xml</code> file. Below are both the <code>struts.xml</code> and the action file:</p>
  
  <p>Struts.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;!-- The core configuration file for the framework is the default (struts.xml) file
  and should reside on the classpath of the webapp (generally /WEB-INF/classes). --&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;!-- devMode equals debug information and reload everything for every request --&gt;
    &lt;constant name="struts.devMode" value="true" /&gt;
    &lt;constant name="struts.ui.theme" value="simple" /&gt;
  
    &lt;package name="faultinjector" extends="struts-default"&gt;
  
      &lt;default-action-ref name="loadexperiments" /&gt;
  
      &lt;action name="loadexperiments" class="faultinjector.action.LoadExperimentsAction" method="execute"&gt;
        &lt;result name="success"&gt;/index.jsp&lt;/result&gt;
      &lt;/action&gt;
  
    &lt;/package&gt;
  
  &lt;/struts&gt;
  </code></pre>
  
  <p>LoadExperimentsAction.java:</p>
  
  <pre><code>public class LoadExperimentsAction extends ActionSupport
  {
      private static final long serialVersionUID = 4L;
  
      private ExperimentService service;
      private List &lt;Experiment&gt; experiments;
  
      @Override
      public String execute()
      {
          System.out.println("Hello!");
  
          return SUCCESS;
      }
  
      public ExperimentService getService()
      {
          return service;
      }
  
      public void setService(ExperimentService service)
      {
          this.service = service;
      }
  
      public List&lt;Experiment&gt; getExperiments()
      {
          return experiments;
      }
  
      public void setExperiments(List&lt;Experiment&gt; experiments)
      {
          this.experiments = experiments;
      }
   }
  </code></pre>