title: Access-Control-Allow-Origin: * in tomcat
body: <p>I want to set a default http header in my tomcat container - </p>
  
  <blockquote>
    <p>Access-Control-Allow-Origin: *</p>
  </blockquote>
  
  <p>From various different links on stackoverslow and from google, most have pointed to a <a href="http://www.skill-guru.com/blog/2011/02/23/cross-domain-scripting-settings-on-tomcat/" rel="noreferrer">resource</a>. <a href="http://feed.openmrs.org/tag/tomcat" rel="noreferrer">This</a> again says same on how to do it. I have replicated the same, but still the header is not shown.
  This is what I have done:
  1) Copied cors.jar file in /lib folder of tomcat
  2) Inserted this text in web.xml</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;CORS&lt;/filter-name&gt;
      &lt;filter-class&gt;com.thetransactioncompany.cors.CORSFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
       &lt;param-name&gt;cors.allowOrigin&lt;/param-name&gt;
          &lt;param-value&gt;*&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
       &lt;param-name&gt;cors.supportedMethods&lt;/param-name&gt;
          &lt;param-value&gt;GET, POST, HEAD, PUT, DELETE&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
       &lt;param-name&gt;cors.supportedHeaders&lt;/param-name&gt;
          &lt;param-value&gt;Content-Type, Last-Modified&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.exposedHeaders&lt;/param-name&gt;
          &lt;param-value&gt;Set-Cookie&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;cors.supportsCredentials&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;CORS&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>It doesn't work and I am helpless. My tomcat version is -6.0.6. Please help.</p>