title: "Access-Control-Allow-Origin:*" has no influence in REST Web Service
body: <p>I make an AJAX call from JavaScript client (running on machine A) to Web server (running on machine B).
  Client tries to access a URL exposed by RESTful Web service (Jersey), and it is blocked with error: </p>
  
  <blockquote>
    <p>Origin <a href="http://localhost/">http://localhost/</a> is not
    allowed by
    Access-Control-Allow-Origin</p>
  </blockquote>
  
  <p>In server I added 2 header parameters that allow access to any client. However it didn't help:</p>
  
  <pre><code>@Context
  private HttpServletResponse servlerResponse;
  
  @POST
  @Path("testme")
  public void test(){
      servlerResponse.addHeader("Access-Control-Allow-Origin", "*");
      servlerResponse.addHeader("Access-Control-Allow-Credentials", "true");
  }
  </code></pre>
  
  <p>The same headers work in case of JSP:</p>
  
  <pre><code>&lt;%
      response.addHeader("Access-Control-Allow-Origin", "*");
      response.addHeader("Access-Control-Allow-Credentials", "true");
  %&gt;
  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;test jsp&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  test
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Am I missing something?</p>
  
  <p>thanks</p>
  
  <p>P.S the client part is:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "http://localhost:8080/login/testme",
      dataType: 'json',
      success: onLoginSuccess,
      error: onLoginError
  });
  </code></pre>