zoukankan      html  css  js  c++  java
  • 第六次作业

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
    <head>
    <title>登录页面</title>
    <style type="text/css">
    body {
        font-size: 16px;
    }
    </style>
    
    <script type="text/javascript">
        function mycheck() {
            if (form1.userName.value == "") {
                alert("用户名不能为空,请输入用户名!");
                form1.userName.focus();
                return;
            }
            if (form1.password.value == "") {
                alert("密码不能为空,请输入密码!");
                form1.password.focus();
                return;
            }
            if (form1.validationCode.value == "") {
                alert("验证码不能为空,请输入验证码!");
                form1.validationCode.focus();
                return;
            }
            if (form1.validationCode.value != form1.validationCode1.value) {
                alert("请输入正确的验证码!");
                form1.validationCode.focus();
                return;
            }
        }
    </script>
    
    </head>
    
    <body bgcolor="pink">
    
        <form action="loginCheck.jsp" name="form1" method="post">
            用户名:<input type="text" name="userName" size="16"> <br>&nbsp;&nbsp;&nbsp;码: <input type="password" name="password"
                size="16"> <br> 验证码:<input type="text"
                name="validationCode"
                onKeyDown="if(event.keyCode==13){form1.submit.focus();}" size="6">
    
            <%
                int intmethod1 = (int) (Math.random() * 10);
                int intmethod2 = (int) (Math.random() * 10);
                int intmethod3 = (int) (Math.random() * 10);
                int intmethod4 = (int) (Math.random() * 10);
                //将得到的随机数进行连接 
                String intsum = intmethod1 + "" + intmethod2 + intmethod3
                        + intmethod4;
            %>
    
            <input type="hidden" name="validationCode1" value="<%=intsum%>">
            <img src="image/<%=intmethod1%>.jpg"> <img
                src="image/<%=intmethod2%>.jpg"> <img
                src="image/<%=intmethod3%>.jpg"> <img
                src="image/<%=intmethod4%>.jpg"> <br> <input type="submit"
                name="submit" value="登录" onfocus="mycheck()"> &nbsp;&nbsp;&nbsp; <input
                type="reset" value="重置">
        </form>
    
    </body>
    
    </html>
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
    
    <head>
    
    <title>处理登录页面的数据</title>
    </head>
    
    <body bgcolor="black">
    
        <%
            request.setCharacterEncoding("UTF-8");
            String name = request.getParameter("userName");
            String password = request.getParameter("password");
            if (request.getParameter("validationCode1").equals(
                    request.getParameter("validationCode"))) {
                if (name.equals("xinfeng") && (password.equals("981107"))) {
                    session.setAttribute("userName", name);
                    response.sendRedirect("main.jsp");
                } else {
                    response.sendRedirect("login.jsp");
                }
            } else {
                response.sendRedirect("login.jsp");
            }
        %>
    
    </body>
    
    </html>
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
    
    <head>
    
    <title>系统主页面</title>
    </head>
    
    <body bgcolor="pink">
    
        <%
            Object name = session.getAttribute("userName");
            String name1 = (String) name;
        %>
        您好<%=name1%>,欢迎您访问!
        <br>
        <a href="exit.jsp">[退出系统]</a>
    </body>
    
    </html>
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
    <head>
    <title>退出系统</title>
    </head>
    <body>
        <%
            session.invalidate();
            response.sendRedirect("login.jsp");
        %>
    </body>
    </html>
  • 相关阅读:
    (BFS 二叉树) leetcode 515. Find Largest Value in Each Tree Row
    (二叉树 BFS) leetcode513. Find Bottom Left Tree Value
    (二叉树 BFS DFS) leetcode 104. Maximum Depth of Binary Tree
    (二叉树 BFS DFS) leetcode 111. Minimum Depth of Binary Tree
    (BFS) leetcode 690. Employee Importance
    (BFS/DFS) leetcode 200. Number of Islands
    (最长回文子串 线性DP) 51nod 1088 最长回文子串
    (链表 importance) leetcode 2. Add Two Numbers
    (链表 set) leetcode 817. Linked List Components
    (链表 双指针) leetcode 142. Linked List Cycle II
  • 原文地址:https://www.cnblogs.com/ZERO-FLY/p/12865557.html
Copyright © 2011-2022 走看看