After reading various tutorials and online documentation, I'm still struggling to figure out how to pass parameters from a JSP form. Below is the JavaScript script I am using:
var app = angular.module('myApp', []);
app.controller('FormController', FormController);
//add dependencies
FormController.$inject = ['$scope', '$http'];
function FormController($scope, $http) {
$scope.blob = {};
$scope.submitForm = function() {
$http({
method : 'POST',
url : '/javaAngularJS',
data : $scope.blob,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
});
};
}
This is the form I have created:
<div class="site-body" ng-app="myApp">
<form ng-controller="FormController" ng-submit="submitForm()">
<p>Blob Key: <input type='input' name='blob-key' ng-model="blob.key"></p>
<p>Ancestor: <input type='text' name='ancestor' ng-model="blob.ancestor"></p>
<input type="submit" class="btn btn-primary" value="Submit">
</div>
Although I have successfully used Angular and AJAX calls for other tasks, I am currently stuck on this issue. Does anyone know how I can correctly retrieve the form parameters in my Servlet? For example, I would like to print the parameters using System.out.println.