@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);

        Map<String, String[]> params = request.getParameterMap();
        if (!params.containsKey("words")) {
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            response.getWriter().println("param words not found");
            return;
        }

        if (params.containsKey("id")) {
            long id = 0;
            try {
                id = Long.parseLong(params.get("id")[0]);
            } catch (Exception e) {
                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                response.getWriter().println("id not type long");
            }
            if (spellCheckMap.containsKey(id)) {
                BKTree bkTree = spellCheckMap.get(id);
                for (String s : params.get("words")[0].split(",")) {
                    bkTree.add(s.trim());
                }
                response.getWriter().println("new words added");
            } else {
                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                response.getWriter().println("id not found");
            }
        } else {
            long id = new Date().getTime();
            BKTree bkTree = new BKTree();
            for (String s : params.get("words")[0].split(",")) {
                bkTree.add(s.trim());
            }
            JSONObject object = new JSONObject();
            try {
                object.put("id", id);
                response.getWriter().println(object.toString());
                spellCheckMap.put(id, bkTree);
            } catch (JSONException e) {
                e.printStackTrace();
                response.getWriter().println("Something is wrong with the service right now...");
            }
        }
    }