• jsp第5次作业


    login.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>
    </head>
    <body>
            <form action="dologin.jsp" method = "post">
                
                姓名:<input type="text" name="uname"/><br/>
                密码:<input type="password" name="upwd"/><br/>
                <input type="submit" value="登录"/><br/>
            </form>
    </body>
    </html>

    dologin.jsp界面:

    <%@page import="javax.websocket.Session"%>
    <%@page import="java.nio.channels.SeekableByteChannel"%>
    <%@ 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>
    </head>
    <body>
            <% 
                request.setCharacterEncoding("utf-8");
                String name =request.getParameter("uname");
                String pwd = request.getParameter("upwd");
                if(name.equals("zs")&&pwd.equals("123")){
                    session.setAttribute("uname", name);
                    session.setAttribute("upwd", pwd);
                    request.getRequestDispatcher("Welcome.jsp").forward(request, response);
                }else{
                    response.sendRedirect("login.jsp");
                }
            
            
            %>
    </body>
    </html>

    Welcome.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>
    </head>
    <body>
            欢迎您:
            <%
                String name = (String)session.getAttribute("uname");
                out.print(name);
            %>
    </body>
    </html>

     

  • 相关阅读:
    香港两日游的那些事儿
    香港两日游的那些事儿
    Node.js下的Hello World
    Node.js下的Hello World
    Node.js下的Hello World
    WP SyntaxHighlighter 初探
    WP SyntaxHighlighter 初探
    WP SyntaxHighlighter 初探
    Google的代码高亮-code-prettify
    Java 18套JAVA企业级大型项目实战分布式架构高并发高可用微服务电商项目实战架构
  • 原文地址:https://www.cnblogs.com/hyonf/p/14641695.html
Copyright © 2020-2023  润新知