zoukankan      html  css  js  c++  java
  • 第九次jsp

    <body>
        <script type="text/javascript">
            function yz() {
                if (form1.userName.value == "") {
                    alert("用户名不能为空");
                    form1.userName.focus();
                    return form1();
                }
                if (form1.userPassword.value == "") {
                    alert("密码不能为空");
                    form1.userPassword.focus();
                    return form1();
                }
                form1.registerid();
            }
        </script>
        <form action="register" method="post" name="form1">
            <table>
                <tr>
                    <td>用户名:</td>
                    <td><input type="text" name="userName" id="userName"
                        placeholder="请输入用户名"></td>
                </tr>
                <tr>
                    <td>密码:</td>
                    <td><input type="password" name="userPassword"
                        id="userPassword" placeholder="请输入密码"></td>
                </tr>
                <tr>
                    <td><br></td>
                </tr>
                <tr>
                    <td><input type="submit" name="registerid" value="注册"
                        onClick="yz()"></td>
                </tr>
            </table>
        </form>
    </body>
    index.jsp
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doPost(request, response);
        }
    
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html");
            response.setCharacterEncoding("utf-8");
            PrintWriter out = response.getWriter();
            String userName = request.getParameter("userName");
            String userPassword = request.getParameter("userPassword");
            if (userName=="" || userPassword=="") {
                System.out.println("注册失败");
                response.sendRedirect("index.jsp");
            }else{
                System.out.println("注册成功");
                System.out.println("用户名:" + userName + "密码:" + userPassword);
                request.getRequestDispatcher("login.jsp").forward(request, response);
            }
            out.flush();
            out.close();
        }
    register.java

     

  • 相关阅读:
    []*T *[]T *[]*T 傻傻分不清楚
    Linux设备树
    gdb使用
    LockBit 2.0 勒索软件全球肆虐,我们该如何防范?
    记一次粗浅的钓鱼样本分析过程
    部分sql注入总结
    Linux系统取证简述
    对抗样本攻击及防御实战
    区块链是否真的安全?黑客盗取价值6亿美金数字货币
    某团购CMS的SQL注入漏洞代码审计
  • 原文地址:https://www.cnblogs.com/zf08/p/12992393.html
Copyright © 2011-2022 走看看