0

This is my jquery code

//jquery
<script>
$.post("dashboardcon", $("#date").serialize(), function(responseHtml) {
    $('#date').html(responseHtml); 
});
</script>

html

<form>
    Date :<br> <input id="date" type="text" name="date">
         <input type="submit" value="Submit">
</form>

servlet

@WebServlet("/dashboardcon")
public class dashboardCon extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        JSONObject jObj = new JSONObject();
        try {
            JSONObject newObj = jObj.getJSONObject(request.getParameter("date"));
            System.out.println(newObj);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49

1 Answers1

0

You must have something like this on your servlet:

 JSONObject jObj    = new JSONObject();
 JSONObject newObj = jObj.getJSONObject(request.getParameter("date"));

Whichi i cant see in your code.

Fotis Grigorakis
  • 363
  • 1
  • 3
  • 16