实验二 JSP的内置对象

一、实验目的

  通过编程和上机实验理解 JSP各个页面之间的响应和传递的过程。并且能够熟练的掌握JSP的内置对象的属性和方法,并能灵活运用。

二、实验要求

1. 基础练习:内置对象常用方法的使用。
2. 编写获取表单数据。
3. 按照下列要求实现简单注册、登录程序。

三、实验代码及运行页面

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/10/13
  Time: 20:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>我的账户页面</title>
    <style>
      .w{
        /*text-align: center;*/
        background-color: #ccc;
        width: 450px;
        height: 225px;
        margin: 50px auto;
      }
      .t{
        text-align: left;
        padding: 15px;
      }
      label{
        display: inline-block;
        text-align: right;
        width: 65px;
        padding: 10px 15px;
      }
      input{
        display: inline-block;
        text-align: left;
        margin: 10px;
      }
      .submit{
        display: inline-block;
        margin: 0px 20px;
      }
      .b div{
        margin: 0 80px;
      }
      .a{
        display: inline-block;
      }
      .check{
        color:#A7482A ;
      }
    </style>
  </head>
  <body>
  <div class="w">
    <div class="t"><strong>请登录...</strong></div>
    <div class="b">
      <div>
        <label>用户名:</label>
        <span><input type="text"></span>
      </div>
      <div>
        <label >密码:</label>
        <span><input type="password"></span>
      </div>
      <div>
        <span class="check"><input type="checkbox" >记住用户名</span>
      </div>
      <div>
          <span>
            <a href="login.jsp"><input type="submit" value="注册"></a>
            <input type="submit" value="登录" class="submit">
          </span>
      </div>
    </div>
  </div>
  </body>
</html>

在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/10/13
  Time: 20:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册页面</title>
    <style>
        .w{
            /*text-align: center;*/
            background-color: #ccc;
            width: 580px;
            height: 430px;
            margin: 50px auto;
        }
        .t{
            text-align: left;
            margin: 10px;
        }
        label{
            display: inline-block;
            text-align: right;
            width: 155px;
        }
        input{
            display: inline-block;
            text-align: left;
            margin: 10px;
        }
        .submit{
            display: inline-block;
            margin: 10px 290px;
        }
        .agree{
            margin: 0 165px;
        }
        .agree span{
            color:#A94424;
        }
        a{
            color:#F9991F;
        }
    </style>
</head>
<body>
<div class="w">
    <form action="login_success.jsp">
            <div class="t">
                <strong>欢迎您注册为本网站的会员,请在下面表单填写注册信息,要求每项必填,信息务必真实,方便我们联系您,谢谢!</strong>
            </div>
            <div>
                <div>
                    <label>用户名:</label>
                    <span><input type="text" name="userName"></span>
                </div>
                <div>
                    <label>学号:</label>
                    <span><input type="text" name="id"></span>
                </div>
                <div>
                    <label >密码:</label>
                    <span><input type="password" name="pwd"></span>
                </div>
                <div>
                    <label>密码确认:</label>
                    <span><input type="password"></span>
                </div>
                <div>
                    <label>电子邮件:</label>
                    <span><input type="text" name="email"></span>
                </div>
                <div>
                    <label>电话:</label>
                    <span><input type="text" name="modile"></span>
                </div>
                <div>
                    <label>地址:</label>
                    <span><input type="text" name="address"></span>
                </div>
                <div class="agree">
                    <span class="check"><input type="checkbox">我同意<a href="javascript:;">相关协议和政策</a></span>
                </div>
                <div>
                    <span><input type="submit" value="注册" class="submit"></span>
                </div>
            </div>
    </form>
</div>
</body>
</html>

在这里插入图片描述

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/10/13
  Time: 20:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册成功页面</title>
    <style>
        a{
            color:#F99E30
        }
        .w{
            width: 600px;
            height: 250px;
            background-color: #ccc;
            margin: 30px auto;
        }
        .t{
            padding: 15px;
        }
        .sub{
            padding: 15px;
        }

    </style>
</head>
<body>
<%
    String name=request.getParameter("userName");
    String id=request.getParameter("id");
    String pwd=request.getParameter("pwd");
    String email=request.getParameter("email");
    String modile=request.getParameter("modile");
    String address=request.getParameter("address");
%>
<div class="w">
    <div class="t"><strong>欢迎您注册为本网站的会员,您的注册信息如下,请记住您的注册信息!</strong></div>
    <div class="sub">用户注册信息:</div>
    <b>用户名:</b><%=name%><br>
    <b>学号:</b><%=id%><br>
    <b>密码:</b><%=pwd%><br>
    <b>电子邮箱:</b><%=email%><br>
    <b>电话:</b><%=modile%><br>
    <b>地址:</b><%=address%><br>
        <a href="index.jsp">返回首页</a>
</div>
</body>
</html>

在这里插入图片描述
在这里插入图片描述

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

玳宸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值