19. [TD] Elections with cross-domain requests
Keywords: CORS (Cross-Origin Resource Sharing).
Here, we will create a new project so that the secure election web service accepts cross-origin 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 value jSON is as follows:
[{"id":1,"version":8,"nom":"A","voix":32000,"sieges":0,"elimine":false},{"id":2,"version":12,"nom":"B","voix":25000,"sieges":0,"elimine":false},{"id":3,"version":13,"nom":"C","voix":16000,"sieges":0,"elimine":false},{"id":4,"version":12,"nom":"D","voix":12000,"sieges":0,"elimine":false},{"id":5,"version":13,"nom":"E","voix":8000,"sieges":0,"elimine":false},{"id":6,"version":12,"nom":"F","voix":4500,"sieges":0,"elimine":false},{"id":7,"version":12,"nom":"G","voix":2500,"sieges":0,"elimine":false}]
In [2], the fields [sieges] and [elimine] have been calculated. We copy the [body] field from [2] to [3] below:
![]() |
The [dbelections] database is then as follows:
![]() |






