zoukankan      html  css  js  c++  java
  • 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>

     

  • 相关阅读:
    HDU5620 KK's Steel(C++语言版)
    HDU5620 KK's Steel(C语言版)
    大整数分解算法
    大整数分解算法
    HDU1319 POJ1595 UVA406 UVALive5490 ZOJ1312 Prime Cuts【素数筛选+打表】
    HDU1106 排序
    B00004 atoi函数
    B00004 atoi函数
    HDU1262 寻找素数对
    HDU1262 寻找素数对
  • 原文地址:https://www.cnblogs.com/hyonf/p/14641695.html
Copyright © 2011-2022 走看看