protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		InputStream is = request.getInputStream();
		// alternatively, one can convert inputstream to string using IOUtils
		// IOUtils.toString(is, "UTF-8");
		if (is != null) {
			/*
			 * lets get input stream reader to get access to the body of the
			 * request
			 */
			InputStreamReader isr = new InputStreamReader(is);
			BufferedReader br = new BufferedReader(isr);
			String objStr = null;
			String s = null;
			/* Retrieve the whole of string */
			while ((s = br.readLine()) != null) {
				if (objStr == null)
					objStr = s;
				else
					objStr = objStr + s;
			}
			/* if (request.getParameter("action").equals("add")) { */
			if (objStr != null && objStr.length() > 0) {
				JSONObject js = new JSONObject(objStr);
				String action = js.getString("action");
				JSONObject jso = new JSONObject();
				PrintWriter pw = response.getWriter();
				if (action.equals("add")) {
					try {
						JSONObject obj = js.getJSONObject("student");
						String fn = obj.getString("firstName");
						String ln = obj.getString("lastName");
						String email = obj.getString("email");
						int dpt = obj.getInt("department");
						int sem = obj.getInt("semester");
						int sec = obj.getInt("section");
						String pass = obj.getString("password");

						String rn = obj.getString("rollNo");

						Student std = new Student(fn, ln, email, pass, dpt, sem, sec, rn);
						// StudentData.writeObject(std);
						stdb.writeObject(std);
						/*
						 * This part of the code will have the logic of updating
						 * database
						 */
						response.setContentType("application/json");
						/* Write the status of the processing to this output */
						jso.put("status", true);
						jso.put("status_code", 0);

						jso.put("status_message", "Student API success");

					} catch (ProvisionException e) {
						jso.put("status", false);
						jso.put("status_code", 0);
						jso.put("status_message", e.getErrorMessage());
					}
					pw.print(jso.toString());
				}
				// teacher
				if (action.equals("add1")) {
					try {
						JSONObject obj = js.getJSONObject("teacher");
						String fn = obj.getString("firstName");
						String ln = obj.getString("lastName");
						String email = obj.getString("email");
						int dpt = obj.getInt("department");
						String pass = obj.getString("password");
						int tid = obj.getInt("teacherId");

						Teacher tch = new Teacher(fn, ln, email, pass, dpt, tid);
						// StudentData.writeObject(std);
						stdb.writeObject(tch);
						/*
						 * This part of the code will have the logic of updating
						 * database
						 */
						response.setContentType("application/json");
						/* Write the status of the processing to this output */
						jso.put("status", true);
						jso.put("status_code", 0);

						jso.put("status_message", "Teacher API success");

					} catch (ProvisionException e) {
						jso.put("status", false);
						jso.put("status_code", 0);
						jso.put("status_message", e.getErrorMessage());
					}
					pw.print(jso.toString());
				}
			}
		}
	}