I'm developing a Backend application using Java and Servlet. I'm using Postman to simulate my client that will send me POST requests.
The thing is, my Client will send me data (key and value) using the HTTP Body part rather than params. On postman I can simulate it filling KEY and VALUE on the Body part as form-data. On the server side, people recommend this:
String login = request.getParameter("login");
But since the client is sending the parameters to me using the body, the above function returns me null (only works if I use params tab on Postman, which is not my client behavior). I was able to read the body using:
String line = null;
while ((line = request.getReader().readLine()) != null)
System.out.println(line);
But the data I get is like:
----------------------------655577064367924555315251
Content-Disposition: form-data; name="login"
matheus
Which means that I'd have to parse that string to transform it on a map<String,String>, which I'm pretty sure that it's not the best whey to handle it.
There is any way that I can pass a KEY("login") to retrieve the VALUE(matheus) from the Body as made on params?
*** SOLUTION ***
It was missing the annotation:
@MultipartConfig