title: Integrate struts2 application with rest API
body: <p>I'm trying to implement a Rest interface for an existing struts2 application (migrating from webProject to Maven), making it work alongside the existing "action" calls.<br>
  I'm completely new to struts and maven, so I tried to follow this tutorial <a href="http://www.concretepage.com/struts-2/struts-2-rest-web-service-integration-example" rel="nofollow">http://www.concretepage.com/struts-2/struts-2-rest-web-service-integration-example</a>.<br>
   The problem seems to be linked with the cohexistence in web.xml of the <code>&lt;filter&gt;</code> and <code>&lt;servlet&gt;</code> tags.<br>
  Here's the code</p>
  
  <p><strong>the rest controller</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>package rest;
  
  import csv.caiq.DataCaiq;
  import java.util.Map;
  import org.apache.struts2.rest.DefaultHttpHeaders;
  import org.apache.struts2.rest.HttpHeaders;
  import com.opensymphony.xwork2.ModelDriven;
  
  public class CaiqController implements ModelDriven&lt;Object&gt; {
  
      private static final long serialVersionUID = 1L;
      private String id;
      private Object model;
      private DataCaiq datacaiq = new DataCaiq();
  
      private static Map&lt;String,String&gt; map;
      {
          for (int i=0; i&lt; datacaiq.getListCaiqs().size();i++)
          map.put(datacaiq.getListCaiqs().get(i).get(1),datacaiq.getListCaiqs().get(i).get(2));
      }
  
      public HttpHeaders index() {
          model = map;
          return new DefaultHttpHeaders("index").disableCaching();
      }
  
      @Override
      public Object getModel() {
          return model;
      }    
  }
  </code></pre>
  
  <p>Here's implemented only index() and getmodel() methods for testing purposes.</p>
  
  <p><strong>web.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;!DOCTYPE web-app PUBLIC
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
  
  &lt;web-app&gt;
  &lt;display-name&gt;Sl Evaluation&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;servlet&gt;
  &lt;servlet-name&gt;action&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;config&lt;/param-name&gt;
    &lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;action&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>struts.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
  "http://struts.apache.org/dtds/struts-2.3.dtd"&gt;
  &lt;struts&gt;
  &lt;constant name="struts.convention.action.suffix" value="Controller"/&gt;
  &lt;constant name="struts.convention.action.mapAllMatches" value="true"/&gt;
  &lt;constant name="struts.convention.default.parent.package" value="rest-default"/&gt;
  &lt;constant name="struts.convention.package.locators" value="rest"/&gt;
  &lt;/struts&gt; 
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;SecurityReasoner&lt;/groupId&gt;
  &lt;artifactId&gt;SecurityReasoner&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  name&gt;SecurityReasoner&lt;/name&gt;
  &lt;build&gt;
  &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
  &lt;resources&gt;
    &lt;resource&gt;
      &lt;directory&gt;src&lt;/directory&gt;
      &lt;excludes&gt;
        &lt;exclude&gt;**/*.java&lt;/exclude&gt;
      &lt;/excludes&gt;
    &lt;/resource&gt;
  &lt;/resources&gt;
  &lt;plugins&gt;
    &lt;plugin&gt;
      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
      &lt;version&gt;3.3&lt;/version&gt;
      &lt;configuration&gt;
        &lt;source&gt;1.7&lt;/source&gt;
        &lt;target&gt;1.7&lt;/target&gt;
      &lt;/configuration&gt;
    &lt;/plugin&gt;
    &lt;plugin&gt;
      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.6&lt;/version&gt;
      &lt;configuration&gt;
        &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
      &lt;/configuration&gt;
    &lt;/plugin&gt;
  &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;dependencies&gt;
       ......
  </code></pre>
  
  <p>Any suggestions? Thanks</p>