title: Cross Domain Scripting Enabling
body: <p>I'm working with Tomcat and I am having some problems with Access-Control-Allow-Origin.</p>
  
  <p>To my understanding, I can modify my web service's web.xml file to open the service up to the world. (Not sure how to do this for sure, but I don't want to anyway.)</p>
  
  <p>How do I add a filter to allow specific websites to interact with it? eg my1.website.com, my2.website.com, and of course it's self.</p>
  
  <p>The area of web.xml I believe should be modified is this...</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;description&gt;My Description&lt;/description&gt;
      &lt;display-name&gt;My Service's Display Name&lt;/display-name&gt;
      &lt;servlet-name&gt;My Servlet's Name&lt;/servlet-name&gt;
      &lt;servlet-class&gt;My Servlet's Class&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;My Servlet's Name&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/MyPattern&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Do I use something like CORS and add...</p>
  
  <pre><code>&lt;servlet&gt;
      .
      .
      .
      &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;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;CORS&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
          &lt;url-pattern&gt;my1.website.com&lt;/url-pattern&gt;
          &lt;url-pattern&gt;my2.website.com&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>Also, is it possible to do something like...</p>
  
  <pre><code>&lt;url-pattern&gt;*.website.com&lt;/url-pattern&gt;
  </code></pre>
  
  <p>Thanks for any help!</p>