Jetty Cross Origin Filter
Aloha,
I fought this for awhile as well, and found that the final node needs to be:
<filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/*</url-pattern></filter-mapping>
NOT
<filter-mapping> <filter-name>cross-origin</filter-name> <filter-pattern>/*</filter-pattern></filter-mapping>
Here is the link I found to help me: wiki.eclipse.org/Jetty/Feature/Cross_Origin_Filter
After I updated my web.xml file and restarted the jetty server, I was able to make cross domain request using jQuery ajax calls.
Rob
I ran into this when doing crossdomain calls to web apps deployed to GAE. You can add an explicit header to your Servlet(s) responses, like:
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.addHeader("Access-Control-Allow-Origin", "*"); ...}
and also make sure you have a crossdomain.xml policy file in the root of your WAR, like:
<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd"><allow-access-from domain="*"/></cross-domain-policy>
HTH.
I had the same Problem with ActiveMQ Ajax within Jetty Web Server. My Problem was, that the allowed headers field is not accepting a wildcard in form of "*".
For getting ActiveMQ Ajax to work, i also have to add the "Options" Method to the allowedMethods.
Cross-Origin Filter from web.xml:
<filter> <filter-name>cross-origin</filter-name> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> <init-param> <param-name>allowedOrigins</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>allowedMethods</param-name> <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value> </init-param> <init-param> <param-name>allowedHeaders</param-name> <param-value>origin, content-type, accept, authorization</param-value> </init-param> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>*</url-pattern> </filter-mapping>