title: How to read json sent by ajax in servlet
body: <p>I'm new to java and I struggling with this problem for 2 days and finally decided to ask here.</p>
  
  <p>I am trying to read data sent by jQuery so i can use it in my servlet</p>
  
  <p>jQuery</p>
  
  <pre><code>var test = [
      {pv: 1000, bv: 2000, mp: 3000, cp: 5000},
      {pv: 2500, bv: 3500, mp: 2000, cp: 4444}
  ];
  
  $.ajax({
      type: 'post',
      url: 'masterpaket',
      dataType: 'JSON',
      data: 'loadProds=1&amp;'+test, //NB: request.getParameter("loadProds") only return 1, i need to read value of var test
      success: function(data) {
  
      },
      error: function(data) {
          alert('fail');
      }
  });
  </code></pre>
  
  <p>Servlet</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
     if (request.getParameter("loadProds") != null) {
        //how do i can get the value of pv, bv, mp ,cp
     }
  }
  </code></pre>
  
  <p>I really appreciate any help you can provide.</p>