GET request using ajax v java -
i'm writing simple web application completes 1 request custom headers. when tried making request using ajax, gave me cross domain error so: no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8080' therefore not allowed access. when make same request in java using custom headers, works fine. public static string executeget() { string response = ""; try { url url = new url("http://...."); httpurlconnection con = (httpurlconnection) url.openconnection(); con.setrequestmethod("get"); //set custom headers con.setrequestproperty("header1", "2.0"); con.setrequestproperty("header2", "sellingv2"); con.connect(); inputstreamreader reader = new inputstreamreader(con.getinputstream()); scanner scanner = new scanner(reader); while (scanner.hasnext()) { ...