• jsp内置对象作业3-application用户注册


    1,注册页面 zhuCe.jsp

     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3     
     4 <%@ page import = "java.util.*" %>
     5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     6 <html>
     7 <head>
     8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     9 <title>注册</title>
    10 
    11 <script type="text/javascript">
    12 
    13 function zx()
    14 {
    15     window.location.href = "zhuXiao.jsp";
    16 }
    17 
    18 </script>
    19 </head>
    20 <body>
    21 <%!
    22 /*
    23 public void zx()
    24  {
    25     this.getServletContext().removeAttribute("zc");
    26  }
    27 */
    28 %>
    29 
    30 <%
    31 Object obj =application.getAttribute("zc");
    32 
    33 if(obj == null)
    34 {
    35 %>
    36 请注册:<br>
    37 <form action="zccl.jsp" name = "zhc">
    38 用户名:
    39 <input type = "text" name = "yhm"><br>
    40 密码:
    41 <input type ="password" name = "mm"><br>
    42 
    43 <input type ="submit" value="提交">
    44 </form>
    45 <%
    46 }else{
    47     out.print("欢迎再次光临,用户:" + obj.toString().split("#")[1]);
    48 
    49 %>
    50 
    51 <br>
    52 <input type="button"  value = "注销" onclick="zx()">
    53 <%} %>
    54 
    55 </body>
    56 </html>

    2,注册处理页 zccl.jsp

     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     4 <html>
     5 <head>
     6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     7 <title>注册处理页</title>
     8 </head>
     9 <body>
    10 <%
    11 String yhm = request.getParameter("yhm");
    12 String mm = request.getParameter("mm");
    13 
    14 if(yhm.equals("") || mm.equals(""))
    15 {
    16     out.print("用户名及密码不能为空");
    17     
    18 }
    19 else
    20 {
    21     application.setAttribute("zc", yhm + "#" + mm);
    22     out.print("注册成功");
    23 }
    24 
    25 response.setHeader("refresh","3; URL =zhuCe.jsp");
    26 %>
    27 </body>
    28 </html>

    3.注销处理 zhuXiao.jsp

     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     4 <html>
     5 <head>
     6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     7 <title>注销处理</title>
     8 </head>
     9 <body>
    10 <%
    11 application.removeAttribute("zc");
    12 response.sendRedirect("zhuCe.jsp");
    13 %>
    14 </body>
    15 </html>
  • 相关阅读:
    Java基础知识面试题(2021年最新版,持续更新...)整理
    windows10 cmd窗口输出卡住(看这篇就够了)
    windows10 powershell窗口输出卡住(看这篇就够了)
    Golang函数相关
    内存对齐详解
    Go编程模式Pipeline
    管道符、重定向与环境变量(Linux就该这么学第三章)
    GMP模型简介
    新手必须掌握的Linux命令(Linux就该这么学第二章)
    Goland运行项目报错:CreateProcess error=216, 该版本的 %1 与你运行的 Windows 版本不兼容。请查看计算机的系统信息,然后联系软件发布者。
  • 原文地址:https://www.cnblogs.com/dirgo/p/4994129.html
Copyright © 2020-2023  润新知