Java中的表单填充验证
我确实使用servlet签入,它可以工作 如何验证表格填写? 例如,如果用户名已经注册,是否将用户重新发送到.jsp文件 对不起,英语不好Java中的表单填充验证,java,servlets,validation,Java,Servlets,Validation,我确实使用servlet签入,它可以工作 如何验证表格填写? 例如,如果用户名已经注册,是否将用户重新发送到.jsp文件 对不起,英语不好 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // fetch the username that was sent in the request S
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);
}