I would like to send a POST query to a Java servlet from a REACT application. A picture can be sent within this query, as can an array of documents (see picture). In addition, normal parameters such as "durationInMonaten" are also sent. How can I now intercept all these parameters within my servlet?
For the dokumenteArray i tried this:
StringBuffer bufDoku = new StringBuffer();
String lineDoku = null;
try {
BufferedReader reader = request.getReader();
while ((lineDoku = reader.readLine()) != null) {
bufDoku.append(lineDoku);
}
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObjDokument = new JSONObject(bufDoku.toString());
JSONArray dokumenteArray = jsonObjDokument.getJSONArray("dokumenteArray");
But is there a simple way for the formDate Parameters, like this :
part = request.getInputStream();
//Get the Image here
....
//Get the dokumenteArray here
....