Hi,
 
I am new with AngularJS, and trying to make REST call to get users from 
server side.
I am setting cookie at login time using *httpServletRequest.addCookie();* 
function. Cookie is added after successfully logged in and present at 
client side (browser). After that m sending get request using 
*$http.get(url)* with current cookie, but it gives error : 

XMLHttpRequest cannot load http://localhost:8443/rest/user/all. No* 
'Access-Control-Allow-Origin'* header is present on the requested resource. 
Origin 'http://localhost:51257' is therefore not allowed access. The 
response had HTTP status code 500.

My server side web.xml file is looks like,

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xmlns="http://java.sun.com/xml/ns/javaee";
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
 id="WebApp_ID" version="2.5">

 <display-name>SpringWithJersey</display-name>

 <!-- - Location of the XML file that defines the root application context. 
 - Applied by ContextLoaderListener. -->
 <context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>classpath:application-config.xml</param-value>
 </context-param>


 <listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
 </listener>


 <servlet>
 <servlet-name>jersey-serlvet</servlet-name>
 <servlet-class>org.glassfish.jersey.servlet.ServletContainer
</servlet-class>
 <init-param>
 <param-name>javax.ws.rs.Application</param-name>
 <param-value>com.gslab.springjersey.poc.RestApplication</param-value>
 </init-param>
 <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
 <servlet-name>jersey-serlvet</servlet-name>
 <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>
 <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,DELETE,PUT,HEAD</param-value>
 </init-param>
 <init-param> 
 <param-name>allowedHeaders</param-name>
 <!--  <param-value>*</param-value>-->
 <param-value>origin, content-type, accept</param-value>
 </init-param>
 </filter>
 <filter-mapping>
 <filter-name>cross-origin</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>

</web-app>

and client side http call is,

$http.get(url,{ withCredentials: true
                });


I have tried many things to resolve this, but getting same issue. 
Please help.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to