protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		User user = (User) request.getSession().getAttribute("user");
		try {
            String nickname = request.getParameter("nickname");
            String typeStr = request.getParameter("type");
            String number = request.getParameter("number");
            String ccv = request.getParameter("ccv");

            if(nickname.isEmpty() || typeStr.isEmpty() || number.isEmpty() || ccv.isEmpty()){
                String redirectUrl = response.encodeRedirectURL("creditcards.jsp?error=Missing Input Fields");
                response.sendRedirect(redirectUrl);
                return;
            }

            if(number.length() != 16){
                String redirectUrl = response.encodeRedirectURL("creditcards.jsp?error=Credit Card Number Must be 16 digits");
                response.sendRedirect(redirectUrl);
                return;
            }

            if(ccv.length() != 3){
                String redirectUrl = response.encodeRedirectURL("creditcards.jsp?error=CCV Must be 3 digits");
                response.sendRedirect(redirectUrl);
                return;
            }

			UserProcedures.addCreditCardToUser(user, nickname, 
                                               TYPE.valueOf(typeStr),
                                               number, ccv);
			response.sendRedirect("creditcards.jsp");
		} catch (SQLException e) {
			response.sendRedirect("error.jsp?error="+e.toString());
			e.printStackTrace();
		} catch (NicknameExistsException e) {
			response.sendRedirect("creditcards.jsp?error="+e.getMessage());
			e.printStackTrace();
		} catch (Exception e) {
			response.sendRedirect("error.jsp?error="+e.toString());
			e.printStackTrace();
		}

	}