• jsp第五次作业


    loginyanzheng2.jsp

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"
    
        %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
            <style type="text/css">
                body{
                    background-color: azure;
                }
                form{
                    position: fixed;
                    top: 250px;
                    left: 650px;
                    background-color: #ADD8E6;
                    border-radius: 5px;
                }
                div{
                    font-size: 22px;
                    margin-top: 20px;
                    padding-left: 40px;
                }
                input{
                    width: 200px;
                    height: 20px;
                    border-radius: 5px;
                }
                #tj{
                    width: 80px;
                    height: 30px;
            
                    margin-left: 140px;
                        border-radius: 5px;
                        font-size: 16px;
                        margin-bottom: 20px;
                }
            </style>
            
    </head>
    <body>
        <form action="/school/Login.jsp" method="post">
                    <div>账 号:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="username"></div>
                    <div>密 码:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="password"></div>
                    <div>验 证 码:<input type="text" name = "yanzhengma"> <img   src="getcode" alt="看不清,换一张" onclick="change(this)"/></div>
                    <div><input type="submit" id="tj" value="登录" ></div>
                </form>
    
    </body>
    <script type="text/javascript">
        function  change(img) {
            img.src = "getcode?"+new Date().getTime();
            
        }
    </script>
    </html>

    Login.jsp

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"
        import=" javax.servlet.http.HttpSession"
        %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%
    request.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=utf-8");
    response.setCharacterEncoding("UTF-8");
     HttpSession s = request.getSession();
    
     String username = request.getParameter("username");
     String password = request.getParameter("password");
     session.setAttribute("username", username);
     session.setAttribute("password", password);
     response.sendRedirect("/school/success.jsp");
     
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    
    </body>
    </html>

    success.jsp

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"
        import=" javax.servlet.http.HttpSession"
        %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    HttpSession s = request.getSession();
    String username = s.getAttribute("username").toString();
    String password = s.getAttribute("password").toString();
    
    %>
        用户名 : <%=username %><br/>
        密码  : <%=password %>
    </body>
    </html>

     

  • 相关阅读:
    如何使用 Python 進行字串格式化
    骨牌摆放问题 POJ 2411(状态压缩DP)
    ACM/OI中C++常用优化(实用/调试/技巧)代码(语法)
    Windows 系统如何完全卸载 VSCode
    Python 在VSCode中使用
    第十一场训练赛
    L1-046 整除光棍 (20分)
    Problem 330A
    POJ 2187 Beauty Contest (凸包 旋转卡壳)
    程序员:写作能收获什么?
  • 原文地址:https://www.cnblogs.com/M1223631418/p/14607573.html
Copyright © 2020-2023  润新知