title: AngularJS $http params vs data--how to get 'data' on server?
body: <p>Background: using AngularJS form to post data to a Java servlet. </p>
  
  <p>Say I have some model in my $scope, from the form, called firstName:</p>
  
  <p><strong>$http request in controller:</strong></p>
  
  <pre><code>$http({
      method: 'POST',
      url: '/CustomerTrackerApp/JSONManager', 
      params: { firstName: $scope.firstName }
  }).then(function(response) {
       alert(response.data);
  });
  </code></pre>
  
  <p><strong>doPost() method in Servlet:</strong></p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      PrintWriter out = response.getWriter();
      String firstName = request.getParameter("firstName");
      out.println("From Servlet: " + firstName);
  }
  </code></pre>
  
  <p>This successfully alerts "From Servlet: {name entered in form}"</p>
  
  <p>My problem is that the <code>params: { firstName: $scope.firstName, }</code> causes the fields to show up in the url, so I want to use:</p>
  
  <pre><code>$http({
      method: 'POST',
      url: '/CustomerTrackerApp/JSONManager', 
      data: { firstName: $scope.firstName }
  }).then(function(response) {
       alert(response.data);
  });
  </code></pre>
  
  <p>How do I get the value of <code>firstName</code> from, <code>data: { firstName: $scope.firstName }</code>, inside my doPost() and save it in an array?</p>
  
  <p>Thanks so much for the help, I've been Googling for a while and can't find my answer.</p>