@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            PrintWriter out = response.getWriter();
            DiskFileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload fileUpload = new ServletFileUpload(factory);
            List items = fileUpload.parseRequest(request);
            Iterator ir = items.iterator();
            while(ir.hasNext()) {
                FileItem item = (FileItem)ir.next();
                if(item.isFormField()) {
                    String fieldName = item.getFieldName();
                    if(fieldName.equals("username")) {
                        userName = item.getString();
                        userPath = dbPath + userName;
                        File file = new File(userPath);
                        if(!file.exists()) {
                            out.println("Wrong username.");
                            success = false;
                        }
                    }
                    if(fieldName.equals("password") && success) {
                        passWord = item.getString();
                        File passwordFile = new File(userPath + dataPath + "password");
                        BufferedReader in = new BufferedReader(new FileReader(passwordFile));
                        String userPassword = in.readLine();
                        if(!userPassword.equals(passWord)) {
                            out.println("Wrong password.");
                            success = false;
                        }
                    }
                }
            }
        }
        catch (FileUploadException ex) {Logger.getLogger(Signup.class.getName()).log(Level.SEVERE, null, ex);}
        if(success) {response.sendRedirect(response.encodeRedirectURL("home.jsp?usr=" + userName));}
        else {success = true;}
    }