How to send multiple parametrs in HTTP POST request? I am sending POST request through Ajax call to servlet I tried below two ways but neither worked
Approach 1:
httpRequest.open("POST", "http://localhost/Servlet/ps" , true);
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
.
.
.
httpRequest.send("msg="+data & "TC="+TC);
At Servlet:
String data = req.getParameter("msg"); // this prints value fine
String TestCaseNo = req.getParameter("TC"); // this prints null
Approach 2:
httpRequest.open("POST", "http://localhost/Servlet/ps" , true);
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
.
.
.
httpRequest.send("msg="+data + "TC="+TC);
ANSWER:This is how it worked for me
var value="msg="+data+"&TC="+TC;
http-Request.send(value);