0

I work with extjs and I use chrome to test my application

in my jsp page I use this code:

function changeContent(url) {


              $( "#cmpframe" ).load( url, function( response, status, xhr ) {

            });

}

<div id = "cmpframe"></div>


changeContent("http://192.168.100.25:8282/bonita/portal/homepage?ui=form#form=test--1.0--Step1$entry&mode=form&task=60002&assignTask=true");

But when I try to run my page I have this error :

 XMLHttpRequest cannot load http://192.168.100.25:8282/bonita/portal/homepage?ui=form. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

this error is related to security .

I add this code without success :

 $( "#cmpframe" ).load( url, function( response, status, xhr ) {
                  response.addHeader("Access-Control-Allow-Origin", "*");

            });

updated :

I try alse with this code

$( "#cmpframe" ).load( url, function( response, status, xhr ) {
                  response.addHeader("Access-Control-Allow-Origin", "*");
 xhr.setRequestHeader("http://192.168.100.25:8282/bonita/portal/homepage?ui=form#form=test--1.0--Step1$entry&mode=form&task=60002&assignTask=true", "XMLHttpRequest");

            });

but I have also this error :

XMLHttpRequest cannot load http://192.168.100.25:8282/bonita/portal/homepage?ui=form. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

in web.xml of tomcat server :

I added this code :

<!-- ================== Built In Filter Definitions ===================== -->

      ...

     <filter>
       <filter-name>CorsFilter</filter-name>
       <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
     </filter>
     <filter-mapping>
       <filter-name>CorsFilter</filter-name>
       <url-pattern>/*</url-pattern>
     </filter-mapping>

    <!-- ==================== Built In Filter Mappings ====================== -->

but I have this error :

java.lang.ClassNotFoundException: org.apache.catalina.filters.CorsFilter
franco
  • 1,829
  • 6
  • 42
  • 75
  • possible duplicate of [How to add an Access-Control-Allow-Origin header](http://stackoverflow.com/questions/5008944/how-to-add-an-access-control-allow-origin-header) and many, many others. – JJJ Jan 17 '15 at 17:37
  • thank you for your response, I have updated my question but I have the same error – franco Jan 17 '15 at 18:26
  • You need to add this header in your backend, like: ` – Scriptable Jan 17 '15 at 18:29
  • "On the requested resource" means the server. It wouldn't be much of a security feature if you could circumvent it like that, would it? – JJJ Jan 17 '15 at 18:34

0 Answers0