19. [TD] Cross-Origin Resource Sharing (CORS)
Keywords: CORS (Cross-Origin Resource Sharing).
Here, we will create a new project so that the secure election web service accepts cross-domain requests.
The Eclipse project is as follows:
![]() |
Task: Follow the process described in Section 18.9 to build this project.
Once this project is built, here is what you can do with the HTML client described in Section 18.2. At the start of the requests, the [dbelections] database is as follows:
![]() | ![]() |
![]() |
![]() |
![]() |
In [1], the posted JSON value is as follows:
[{"id":1,"version":8,"name":"A","votes":32000,"seats":0,"eliminated":false},{"id":2,"version":12,"name":"B","votes":25000,"seats":0,"eliminated":false},{"id":3,"version":13,"name":"C","votes":16000,"seats":0,"eliminated":false},{"id":4,"version":12,"name":"D","votes":12000,"seats":0,"eliminated":false},{"id":5,"version":13,"name":"E","votes":8000,"seats":0,"eliminated":false},{"id":6,"version":12,"name":"F","votes":4500,"seats":0,"eliminated":false},{"id":7,"version":12,"name":"G","votes":2500,"seats":0,"eliminated":false}]
In [2], the [seats] and [eliminated] fields have been calculated. We copy the [body] field from [2] to [3] below:
![]() |
The [dbelections] database is then as follows:
![]() | ![]() |







