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();
}
}