title: Access-Control-Allow-Origin
body: <p>Hi I'm developing a web application using a REST web service as server side. When I make a call to rest web service from my client side it gives me the following error. Servie is running uder <code>http://localhost:8010/service</code> and client is running under <code>http://localhost:8020/client</code>. I have deployed this in jetty. </p>
  
  <pre><code>XMLHttpRequest cannot load http://localhost:8010/Service/rest/employee/basicupdate. Origin http://localhost:8020 is not allowed by Access-Control-Allow-Origin.
  </code></pre>
  
  <p>Below I have included my rest method</p>
  
  <pre><code>@POST
  @Path("/basicupdate")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Context 
  public String isValidLogin(@FormParam("employeeId") int employeeId, @FormParam("firstName") String firstName, @FormParam("lastName") String lastName, @FormParam("gender") String gender, @FormParam("dob") String dob ) throws JsonGenerationException, JsonMappingException, IOException{
      Response response = new Response();
      String responseString = "";
      try {
  
          //Application logic
  
          response.setCode(MessageCode.SUCCESS);
          response.setMessage("Successfully Updated");
  
      } catch (CustomException e) {
          response.setCode(MessageCode.ERROR);
          response.setMessage(e.getMessage());
          e.printStackTrace();
      } catch (Exception e) {
          response.setCode(MessageCode.ERROR);
          response.setMessage(e.getMessage());
          e.printStackTrace();
      }finally{
          responseString = mapper.writeValueAsString(response);
      }   
      return responseString;
  }
  </code></pre>