I need to set "Access-Control-Allow-Origin" to "*" by code.
Reading this i've tried to set org.eclipse.jetty.servlets.CrossOriginFilter
using setInitParameter
:
Server server = new Server(activity.WEB_SERVER_PORT);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setWelcomeFiles(new String[] { "index.html" });
context.setContextPath("/");
context.setInitParameter("org.eclipse.jetty.servlets.CrossOriginFilter", "/*");
TheServlet sv = new TheServlet();
context.addServlet(new ServletHolder(sv),"/servleturl");
server.setHandler(context);
try {
server.start();
} catch (Exception e) { }
But it doesn't work. How can I solve?