private void editConference(HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException { String confNameBeforeEdit = request.getParameter(ProjConst.CONF_NAME_BEFORE_EDIT); Conference origConf = ConferenceDao.getInstance().getConferenceByName(confNameBeforeEdit); String confName = request.getParameter(ProjConst.CONF_NAME); String desc = request.getParameter(ProjConst.CONF_DESC); String location = request.getParameter(ProjConst.CONF_LOCATION); DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date startDate = (Date) formatter.parse(request.getParameter(ProjConst.CONF_START_DATE)); Date endDate = (Date) formatter.parse(request.getParameter(ProjConst.CONF_END_DATE)); Location locationInstance = LocationDao.getInstance().getLocationByName(location); origConf .setName(confName) .setDescription(desc) .setLocation(locationInstance) .setStartDate(startDate) .setEndDate(endDate); JsonObject jsonObject = new JsonObject(); String resultSuccess; String message; try { ConferenceDao.getInstance().updateConference(origConf); message = "Conference successfully edited"; resultSuccess = "true"; } catch (Exception e) { message = "Found problem while editing conference"; resultSuccess = "false"; } response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); try { Gson gson = new Gson(); String json; if (ConferenceDao.getInstance().isConferenceNameExists(confName)) { jsonObject.addProperty("resultSuccess", resultSuccess); jsonObject.addProperty("message", message); json = gson.toJson(jsonObject); } else { jsonObject.addProperty("resultSuccess", "false"); jsonObject.addProperty("message", "Failed to edit conference"); json = gson.toJson(jsonObject); } out.write(json); out.flush(); } finally { out.close(); } }