zoukankan      html  css  js  c++  java
  • session对象练习

    <body>
      <h2 class="a">欢迎来到新闻发布系统</h2>
        <form action="denglu.jsp" >
        <button >登录</button></form>&nbsp;&nbsp;
        <form action="zhuce.jsp" class="b">
        <button>注册</button>
        </form>
      </body>
    <body>
        <h2>注册页面</h2>
        <form action="denglu.jsp" method="get">
        账户:<input type="text" name="zzhanghao" ><br>
        密码:<input type="password" name="zmima">
        <input type="submit" value="注册">
        </form>
    
    <br>
      </body>
    
    zhuce.jsp
    <body>
      <h2>登录页面</h2>
      <%
      String zzh=request.getParameter("zzhanghao");
      String zmm=request.getParameter("zmima");
      session.setAttribute("zzzhanghao", zzh);
      session.setAttribute("zzmima", zmm);
       %>
     <form action="dchuli.jsp" method="get">
          账户:<input type="text" name="dzhanghao"><br>
        密码:<input type="password" name="dmima">
    <input type="submit"  value="登录"></form>
        <br>
      </body>
    
    denglu.jsp
    //登录判断页面
    <body>
       <%
         String dzh=request.getParameter("dzhanghao");
         String dmm=request.getParameter("dmima");
         session.setAttribute("ddzhanghao", dzh);
         session.setAttribute("ddmima", dmm);
         String zzzhanghao=(String)session.getAttribute("zzzhanghao");
         String zzmima=(String)session.getAttribute("zzmima");
         String ddzhanghao=(String)session.getAttribute("ddzhanghao");
         String ddmima=(String)session.getAttribute("ddmima");
       
         if(ddzhanghao==null||ddmima==null){
         ddzhanghao="orr";
         ddmima="orr";
         }
         
          if(zzzhanghao==null||zzmima==null){
    zzzhanghao="eorr";
    zzmima="eorr";
        }
        
     if(zzzhanghao.equals(ddzhanghao)&&zzmima.equals(ddmima)){
     if(zzzhanghao.equals("admin")){
     out.println("后台操作页面"+"</br>");
    out.println("管理员信息"+"</br>");out.print("管理员账号"+ddzhanghao+"登录密码"+ddmima);
     }else{
        request.getRequestDispatcher("index2.jsp").forward(request, response);
        }
        }else{
        //out.print(dzhanghao);
        String a=(String)session.getAttribute("zzzhanghao");
         String b=(String)session.getAttribute("zzmima");
        request.getRequestDispatcher("denglu.jsp").forward(request, response);
        }
        
    
         %>
    <!-- 
     注册账号<%=zzzhanghao %>注册密码<%=zzmima %><br>
     登录账号<%=ddzhanghao %> 登录密码<%=ddmima %>
    -->
       <br>
      </body>
    
    dchuli.jsp
     <!-- 新闻页面 -->
      <body>
       <form action="pyan.jsp">
        
          最新新闻<br><br>评论:<input type="text" name="pinglun"><input type="submit" value="提交评论"><br></form> <br>
      </body>
    <!-- 评论发表 -->
      <body>
      <%
      String py=request.getParameter("pinglun");
      session.setAttribute("pyanzheng", py);
      String yh=(String)session.getAttribute("ddzhanghao");
      String pl=(String)session.getAttribute("pyanzheng");
       %>
       <form action="">
          最新新闻<br><br>评论:<input type="text"><input type="submit" value="提交评论"><br>
          用户:<%= yh%>说:<%= pl%>
          </form> <br>
      </body>
    
    pyan.jsp
     
  • 相关阅读:
    AngularJS SQL
    CSS border-collapse 属性
    AngularJS 表格
    <option> 标签的 value 属性
    AngularJS Select(选择框)
    [Leetcode] N-Queens II
    [Leetcode] N-Queens
    [Leetcode] Climbing Stairs
    [Leetcode] Linked List Cycle II
    [Leetcode] Linked List Cycle
  • 原文地址:https://www.cnblogs.com/mengjia0513/p/12827984.html
Copyright © 2011-2022 走看看