title: POST data as json to a Servlet not working in Phantomjs
body: <p>I am facing very strange issue here. I have a servlet running on my machine which renders my web page based on some input parameters.</p>
  
  <p>Now, my screen capture with PhantomJS is not working if I try to send my data as a JSON object as a POST request type. For e.g. if I try:</p>
  
  <p><strong>Client side</strong></p>
  
  <pre><code>var data = {"op": "get"};
  
  page.open(address, 'POST', data, function (status) {
  if (status !== 'success') {
      console.log('[ERROR] :: Unable to fetch the address - ' + address + ", with data - " + data);
      phantom.exit();
  } else {
      page.render(output);        
  }
  console.log('processing...');
  });
  </code></pre>
  
  <p><strong>Server side</strong></p>
  
  <p>Now, on the server side, I am using Apache Velocity View templating so I have a single method which handles both get and post like : </p>
  
  <pre><code>public Template handleRequest(HttpServletRequest request, HttpServletResponse response,
          Context context){
     System.out.println(request.getParameter("op"));
     //Always null
  }
  </code></pre>
  
  <p>However, if I try sending my data from phantomjs as:</p>
  
  <pre><code>var data = "op=get&amp;..."
  It works
  </code></pre>
  
  <p>Also, at many places elsewhere in my code..I am doing Ajax POST requests to the same servlet and it works perfectly for all those request.</p>
  
  <p>Would anybody explain why my servlet is not reading the JSON parameters passed from Phantomjs?</p>