开发者

Form filling validation in Java

I do check in with a servlet, it works.

How validation of form filling?开发者_开发知识库 For example, re-send the user to .jsp-file, if a username is already registered?

Sorry for bad english.


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);      
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜