zoukankan      html  css  js  c++  java
  • jsp session练习简单的登录

    <%@ 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="lianxi6.jsp" method="post">
    账号:<input type="text" name="name">
    <br>
    密码:<input type="password" name="password" > 
    <br>
    <input type="submit" value="登录">
    </form>
    </body>
    </html>
    <%@ 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=new String (request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
    session.setAttribute("name", name);
    String password=new String (request.getParameter("password").getBytes("ISO-8859-1"),"UTF-8");
    session.setAttribute("password", password);
    %>
    登陆成功
    <%
    response.setHeader("refresh", "5;URL=lianxi7.jsp");
    %>
    </body>
    </html>
    <%@ 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=session.getAttribute("name").toString();
    String password=session.getAttribute("password").toString();
    out.print("账号:"+name);
    out.print("<br>密码:"+password);
    %>
    </body>
    </html>

  • 相关阅读:
    网页源码爬取
    Vue模板语法上集
    SSH整合
    P1290 欧几里德的游戏
    P1582 倒水
    P2158 [SDOI2008]仪仗队
    P1338 末日的传说
    P1372 又是毕业季I
    P1865 A % B Problem
    P1031 均分纸牌
  • 原文地址:https://www.cnblogs.com/wallan/p/5622297.html
Copyright © 2011-2022 走看看