title: CORS enable in servlet
body: <p>I used this header method in my servlet doPost method for enable CORS. Though I get CORS error in my reactjs application at the time of fetching api. reactjs error is here (error: has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.)</p>
  
  <pre><code>    response.addHeader("Access-Control-Allow-Origin", "*");
      response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, HEAD");
      response.addHeader("Access-Control-Allow-Headers", "X-PINGOTHER, Origin, X-Requested-With, Content-Type, Accept");
      response.addHeader("Access-Control-Max-Age", "1728000");
  </code></pre>
  
  <p>In tomcat web.xml i add this with bunch of code which is given below. How I can change param-value for multiple client instead of fixed URL like (<a href="http://localhost:3000" rel="noreferrer">http://localhost:3000</a>) in tomcat?</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;http://localhost:3000&lt;/param-value&gt;
    **(How I can change param-value for multiple client instead of fixed URL)**
  &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;1800&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>