src/java/Controllers/AuthServlet.java
/**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
Handles the HTTP POST method.

@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
Handles the HTTP POST method . @param request servlet request @param response servlet response @throws ServletException if a servlet - specific error occurs @throws IOException if an I / O error occurs
@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String email = request.getParameter("email");
        String username = request.getParameter("username");
        User user = new User();
        UserDAO userDAO = new UserDAO();
        if(email == null)
        {
            String[] keys = {"username"};
            String[] values = {username};
            user = userDAO.getBy(keys, values);
            PrintWriter out = response.getWriter();
            if(user == null)
                out.print("Username available");
            else
                out.print("Username unavailable");
        }
        else
        {
            String[] keys = {"email"};
            String[] values = {email};
            user = userDAO.getBy(keys, values);
            PrintWriter out = response.getWriter();
            if(user == null)
                out.print("Email available");
            else
                out.print("Email unavailable");
        }
    }
@ Override protected void doPost ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { String email = request . getParameter ( "email" ) ; String username = request . getParameter ( "username" ) ; User user = new User ( ) ; UserDAO userDAO = new UserDAO ( ) ; if ( email == null ) { String [ ] keys = { "username" } ; String [ ] values = { username } ; user = userDAO . getBy ( keys , values ) ; PrintWriter out = response . getWriter ( ) ; if ( user == null ) out . print ( "Username available" ) ; else out . print ( "Username unavailable" ) ; } else { String [ ] keys = { "email" } ; String [ ] values = { email } ; user = userDAO . getBy ( keys , values ) ; PrintWriter out = response . getWriter ( ) ; if ( user == null ) out . print ( "Email available" ) ; else out . print ( "Email unavailable" ) ; } }
Handles the HTTP <code>POST</code> method.
Handles the HTTP <code > POST< / code > method .