Reputation: 3647
First, this may be marked as duplicate question, but the other questions were not answered at all.I think no one found it interesting.
I wanted to enable Cross-Site requests in my tomcat server. Google shows that in apache, we can enable a cross site by adding
Access-Control Allow-Origin.
How to get this done in tomcat . I would like two things, First opening access to everyone and second, access for limited sites.
Is it Possible and if so, how can it be done.
How come API's are working , if Cross Site requests are not possible. I can send some data to Paypal server and i get response back. I know that's done in some server side languages(Java,PHP). But i want to know if it's possible from Java Script too,
Upvotes: 4
Views: 6143
Reputation: 3647
I think i found a way for this, when sending Response from the Tomcat Server i.e from Servlets, set the Response Header to have these
Response.setHeader("Access-Control-Allow-Origin","http://www.myserver.com");
And as Chris Commented, it's not in Apache directives.It's only in Response Headers. Hope it's helpful for someone who is trying Cross Domain requests.
Upvotes: 3