I am doing a simple Java Servlet POST request without using any HTML and only using Postman. And the response from getParameter() is always null.
Here is the servlet:
@WebServlet("/api/form")
public class FormServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String orderNumber = req.getParameter("testString");
System.out.println(orderNumber);
resp.getWriter().print(orderNumber);
}
}
And a picture with responses and how I am doing it:

EDIT
As was commented by Mukesh Verma.
All I had to do was add @MultipartConfig Annotation and I got the data.
This is not how method getParameter works. As stated in this question, you should call the servlet with the following URL:
http://localhost:8080/api/form?testString=test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With