title: Reading JQuery data sent from Ajax in Java Servlet
body: <p>Here is my Ajax code:</p>
  
  <pre><code>    var myJSONObject = {"bindings": [
                                       {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}]
                               };
      $.ajax({
          url : "ships",
          data : myJSONObject,
          success : function(data){
              GLOBAL.player.startShooting(data);
          },
          error : function(data) {
              console.log("error:", data);
          },
          dataType : "json",
          timeout : 30000,
          type : "post"
      });
  </code></pre>
  
  <p>And here is my Java Servlet code:</p>
  
  <pre><code>protected void doPost(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
      System.out.println("im in PSOT");
      System.out.println(request.getParameter("myJSONObject"));
  
      StringBuilder sb = new StringBuilder();
      BufferedReader br = request.getReader();
      String str;
      while( (str = br.readLine()) != null ){
          sb.append(str);
      }   
      System.out.println(sb.toString());
      response.setContentType("application/json");
      response.getWriter().write("{\"key\":\"hello\",\"key2\":\"world\"}");
  }
  </code></pre>
  
  <p>The Java servlet returns my Hello World object, but i CANNOT read data in Java Servlet
  The console prints out the following:</p>
  
  <pre><code>im in PSOT
  null
  </code></pre>
  
  <p>The last line is an empty string from last println.</p>
  
  <p>I am using Tomcat 7</p>
  
  <p>Can anyone please tell me what i am doing wrong and why i cannot read data in Java Servlet_</p>