So Im making a rest call to a Ws I have deployed in a different domain name.
How can I pass over cookie in request if its in a different domain?
Origin: profileUI-sandbox.testServer.com
So this is my ajax call
Util.ajax({
url: "https://profileWS-sandbox.testServer.com/rs/myProfile",
dataType : CONSTANTS.DATA_TYP_JSON,
type : 'GET',
success : success,
error : error,
cache: false
});
},
In my server side code I have a filter set in my web.xml going to a servlet to read the cookie etc and do some other stuff before redirecting to the Webservice.
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException
{
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
LOGGER.debug("Adding Access Control Response Headers");
httpResponse.setHeader("Access-Control-Allow-Origin", "*");
httpResponse.setHeader("Content-type", "application/json");
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, HEAD, OPTIONS");
httpResponse.setHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
try {
Cookie cookies[] = httpRequest.getCookies();
LOGGER.debug("Iterating over cookie");
for(Cookie cookie:cookies)
{
LOGGER.debug("cookie.getName():" + cookie.getName());
}
Problem is, my cookie is coming back as null. Im fairly sure this has something to do with the different domains as when I test locally it works fine.
Thoughts?