Enabling CORS on Apache Tomcat 6

Copy cors-filter-<version>.jar file and java-property-utils-<version>.jar to $CATALINA_HOME/lib.

Then, edit the $CATALINA_HOME/conf/web.xml file to include:

<filter>
    <filter-name>CORS</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>CORS</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

It’s important to note that simply using the above configuration options in web.xml will enable public CORS access to the server. You may want to limit the cors.allowOrigin parameter.

See dzhuvinov.com