2011-02-13 9 views
1

서블릿으로 체크인하면 작동합니다.Java에서 양식 채우기 유효성 검사

양식 채우기의 유효성 확인은 어떻게됩니까? 예를 들어 사용자 이름이 이미 등록되어있는 경우 사용자를 .jsp-file로 다시 보냅니다.

죄송합니다.

+0

http://stackoverflow.com/tags/servlets/info – BalusC

답변

2
public void doGet(HttpServletRequest request, HttpServletResponse response) 
    throws ServletException, IOException { 

    // fetch the username that was sent in the request 
    String username = request.getParameter("username"); 

    // TODO: verify if the username is taken in the database 

    // based on the results set the value 
    request.setAttribute("isUsernameTaken", "true"); 

    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/register.jsp"); 

    dispatcher.forward(request, response);  
}