I have a page where user can upload image. I am posting the data to the url using the post request of angular js. My doubt is how do i retrieve this data in servlet. I want save the image in the database. Please let me know if this is the correct approach to perform this activity
//Controller
app.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
$scope.uploadFile = function(){
    var file = $scope.myFile;
    console.log('file is ' + (file));
    var uploadUrl = "/Angular/login";
    fileUpload.uploadFileToUrl(file, uploadUrl);
};
}]);
//Service
app.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function(file, uploadUrl){
    var fd = new FormData();
    fd.append('file', file);
    $http.post(uploadUrl, fd, {
        transformRequest: angular.identity,
        headers: {'Content-Type': undefined}
    })
    .success(function(){
    })
    .error(function(){
    });
}
}]);
//directive
app.directive('fileModel', ['$parse', function ($parse) {
return {
    restrict: 'A',
    link: function(scope, element, attrs) {
        var model = $parse(attrs.fileModel);
        var modelSetter = model.assign;
        element.bind('change', function(){
            scope.$apply(function(){
                modelSetter(scope, element[0].files[0]);
            });
        });
    }
};
}]);
How should i retrieve the above posted data in java servlet..?
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
 
     
    