zoukankan      html  css  js  c++  java
  • session 实现保存用户信息

    index.jsp

     1 <body>
     2     <div style="margin: 0 auto;  500px; text-align: center;">
     3         <img alt="图片" src="logo.jpg" width="200px">
     4         <h1>绿叶网上书店系统</h1>
     5         <form method="post" action="doLogin.jsp">
     6             用户名:<input type="text" name="userName"><br>
     7             查 询:<input type="password" name="pwd"><br>
     8             <input type="submit" value="提交">
     9             <input type="reset" value="取消">
    10         </form>
    11     </div>
    12 </body>

    doLogin.jsp

     1 <body>
     2     <%
     3         request.setCharacterEncoding("UTF-8");
     4         String name = request.getParameter("userName");
     5         String pwd = request.getParameter("pwd");
     6         if("admini".equals(name.trim()) && "admini".equals(pwd.trim())){
     7             session.setAttribute("name", name);
     8             session.setAttribute("pwd", pwd);
     9             response.sendRedirect("showLoginInfo.jsp");
    10         }
    11     %>
    12 </body>

    show.jsp

    1 <body>
    2     <%
    3         String name = (String)session.getAttribute("name");
    4         String pwd = (String)session.getAttribute("pwd");
    5         out.print("欢迎 "+name+" 登录成功!!!! 用户密码为:"+pwd);
    6     %>
    7 </body>
  • 相关阅读:
    哈希表--扩展数组
    哈希表效率
    P=(1+1/(1-L))/2
    函数推进
    简单函数2
    简单函数
    getting data from the keybroad
    nutch-2.2.1 hadoop-1.2.1 hbase-0.92.1 集群部署(实用)
    hbase zookeeper独立搭建
    Orchard 介绍
  • 原文地址:https://www.cnblogs.com/xuqiulin/p/4414842.html
Copyright © 2011-2022 走看看