current position:Home>The Java Web servlet triggers the alert box on the front end

The Java Web servlet triggers the alert box on the front end

2022-04-29 07:42:06qq_ forty-five million eight hundred and sixty thousand nine hu

One , describe

When the password entered fails to log in , Use servlet Trigger front-end alert Box and redirect to the login box, re-enter and then log in . It's like this :
 Insert picture description here
servlet Use the following code for the first time : No reaction results

        String username = req.getParameter("username");
        String password = req.getParameter("password");
        if(userInfoService.login(username, password)){
    
            
        }else {
    
            resp.setContentType("text/html;charset=utf-8");
            resp.getWriter().print("<script language='javascript'>alert(' The account or password you entered is incorrect , Please re-enter !');</script>");
            resp.sendRedirect("/login.html");
        }

servlet Use the following code for the second time : Achieve the desired effect perfectly , very amazing.
The test results are shown in the figure above .

    String username = req.getParameter("username");
        String password = req.getParameter("password");
        if(userInfoService.login(username, password)){
    

        }else {
    
            resp.setContentType("text/html;charset=utf-8");
            resp.getWriter().print("<script language='javascript'>" +
                    "alert(' The account or password you entered is incorrect , Please re-enter !');" +
                    "window.location.href='login.html';</script>')");
        }

copyright notice
author[qq_ forty-five million eight hundred and sixty thousand nine hu],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290541290421.html

Random recommended