I'm developing a jsp which sends POST requests to a servlet. I would like to write content in raw payload instead of key-value form.
var addItemApp = angular.module('addItem',[]);
addItemApp.controller('addItemCtrl', function($scope, $http){
$scope.addItemBnClicked = function(){
var rqst = $http.post('http://127.0.0.1:8180/JSP/ws', "This is a test content");
rqst.success(function(rspnData, status, headers, config){
alert("Status: " + status);
});
}
});
Checking on the server side, I found that the payload doesn't contain anything. Please help, Thanks. ^^
%%%%%%%%%%%%%%% Edit %%%%%%%%%%%%%%%
I use the following code to get the payload.
String line = "";
String rqstRawBody = "";
while((line = servletRqst.getReader().readLine()) != null){
rqstRawBody += line;
}
System.out.println("rqstRawBody: " + rqstRawBody);
The rqstRawBody is finally an empty string. I believe the above java code is okay, as I get raw payload correctly for those requests sent using the chrome-app Rest Client.