I am calling an url using ajax - but when it is called I am getting response HTTP/1.1 403
below is my calling code
function callApi() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint1").innerHTML = this.responseText;
}
}
xmlhttp.open("GET", "http://103.240.91.110/GENCLASS/checkApi.do?
$95599&99&3456790&09012020152103*", true);
xmlhttp.send();
}
Below is the server side method who is sending the response
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value
ApiForm apiForm = (ApiForm)form;
try {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods","GET, OPTIONS, HEAD, PUT, POST");
// send back response
System.out.println("true");
}catch(Exception e){
errors.add(ActionErrors.GLOBAL_ERROR, new org.apache.struts.action.ActionError("load.error.unknown"));
//log.error("Critical Error " + e);
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
forward = mapping.findForward("failure");
} else {
forward = mapping.findForward("success");
}
return (forward);
}
Whenever I am calling the URL I am getting response HTTP/1.1 403 Note that It is working perfectly when I am requesting through browser
I am using tomcat 8.5 on windows on server (called resource) Any assistance will be appreciated