title: CORS doesn't work with tomcat + javascript
body: <p>When sending a XMLHttpRequest</p>
  
  <pre><code>function requireCS(){
  var http = new XMLHttpRequest();
  var url = "url";
  http.open("POST", url, true);
  
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Request", "categories");
  
  http.onreadystatechange = function() {changes.
    if(http.readyState == 4 &amp;&amp; http.status == 200) {
    }
  }
  http.send();
  }
  </code></pre>
  
  <p>I get an error</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load -serverurl-. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.
    script.js:263 XHR failed loading: POST "-serverurl-".</p>
  </blockquote>
  
  <p>I have the header set in web.xml</p>
  
  <pre><code>&lt;filter&gt;
    &lt;filter-name&gt;CorsFilter&lt;/filter-name&gt;
    &lt;filter-class&gt;org.apache.catalina.filters.CorsFilter&lt;/filter-class&gt;
    &lt;init-param&gt;
    &lt;param-name&gt;cors.allowed.origins&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.allowed.methods&lt;/param-name&gt;
     &lt;param-value&gt;GET,POST,HEAD,OPTIONS,PUT&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
    &lt;param-name&gt;cors.allowed.headers&lt;/param-name&gt;
    &lt;param-value&gt;Content-Type,X-Requested-With,accept,Origin,Access-Control-          Request-Method,Access-Control-Request-Headers&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
    &lt;param-name&gt;cors.exposed.headers&lt;/param-name&gt;
    &lt;param-value&gt;Access-Control-Allow-Origin,Access-Control-Allow-    Credentials&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
    &lt;param-name&gt;cors.support.credentials&lt;/param-name&gt;
    &lt;param-value&gt;true&lt;/param-value&gt;
     &lt;/init-param&gt;
     &lt;init-param&gt;
     &lt;param-name&gt;cors.preflight.maxage&lt;/param-name&gt;
     &lt;param-value&gt;10&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;CorsFilter&lt;/filter-name&gt;
     &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
   &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Cannot figure out whats wrong.
  Can you help me?</p>