Note that there are some explanatory texts on larger screens.

plurals
  1. POtomcat 7 cors filter
    primarykey
    data
    text
    <pre><code>Ubuntu 12.10 Tomcat 7.0.41 Chrome 27.0.1453.116 </code></pre> <p>I would like to use Tomcat's new, native <code>CORS</code> filter to allow <code>Access-Control-Allow-Origin: *</code> . The configuration seems simple enough but when I use Chrome's "Developer tools" or Firefox' Firebug to check for <em>Access-Control-Allow-Origin: *</em>, it does not appear in the response header: </p> <pre><code>Request URL:http://XXX.XXX.XX.99:8984/SimpleServlet/simple-servlet Request Method:GET Status Code:200 OK Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive DNT:1 Host:198.100.45.99:8984 User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 Response Headersview source Content-Length:103 Content-Type:text/html;charset=ISO-8859-1 Date:Mon, 24 Jun 2013 00:19:30 GMT Server:Apache-Coyote/1.1 </code></pre> <p>For testing, I've deployed a simple servlet and have configured the following in WEB-INF/web.xml.</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3.0.xsd" version="3.0"&gt; &lt;servlet&gt; &lt;servlet-name&gt;SimpleServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;com.javaranch.codebarn.servletjsp.SimpleServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;SimpleServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/simple-servlet&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &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.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&lt;/param-value&gt; &lt;/init-param&gt; &lt;!-- &lt;init-param&gt; &lt;param-name&gt;cors.logging.enabled&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; --&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; &lt;/web-app&gt; </code></pre> <p>What am I missing? I've also tried Dzhuvinov's java classes/filter and have tried configuring the filter in WEB-INF/web.xml and $CATALINA_BASE/conf/web.xml. What could be blocking this configuration?</p> <p>How can I troubleshoot this? It appears that in the original eBay cors-filter offering, there was a parameter to toggle logging, but this is not reflected in the Tomcat v7.0.41 documentation.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload