编写一个JSP登录页面,可输入用户名和密码,提交请求到另一个JSP页面,该JSP页面获取请求的相关数据并显示出来。请求的相关数据包括用户输入的请求数据和请求本身的一些信息。

实战要求

编写一个JSP登录页面,可输入用户名和密码,提交请求到另一个JSP页面,该JSP页面获取请求的相关数据并显示出来。请求的相关数据包括用户输入的请求数据和请求本身的一些信息。

(例如请求使用的协议getProtocol()、请求的URI request.getServletPath()、请求方法request.getMethod()、远程地址request.getRemoteAddr()等)

 7.jsp  注意:(其中action对应的是另一个代码7.1.jsp名称)

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        .a{
            border-style: solid ;
            border-color: purple;
            width: 30%;
            height: 40%;
            margin: auto;
            /*position: absolute;*/
            /*left: 0;*/
            /*top: 0;*/
            /*bottom: 0;*/
            /*right: 0;*/
            background-color: lightgrey;
        }
        .b{
            text-align: center ;
            background-repeat: no-repeat ;
            background-position:center center;
            background-size:cover;
            background-attachment: fixed;
        }
    </style>
</head>
<body background="/photo/zhongguo3.jpg" class='b'>
<div align="center" class='a'>
    <form   name="form1" action="7.1.jsp" method="post">
        <h1 style="color: red">用户登录</h1>
        <h2>用户名:<input type="text" name="username"></h2>
        <h2>密&nbsp&nbsp&nbsp码:<input type="password" name="password"></h2>
        <h2><input type="submit" value="提交" style="margin-right: 50px">
            <input type="reset" value="取消"></h2>
    </form>
</div>
</body>
</html>

7.1.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body background="/photo/zhongguo2.jpg">
<div  align="center" >
<%--    color的颜色可自行设置--%>
    <h1 style="color: black">登录提交成功页面</h1>
    <hr size="2" color="blue">
    <h3>用户名:<%=request.getParameter("username") %></h3>
    <h3>密码:<%=request.getParameter("password") %></h3>
    <hr size="2" color="green">
    <h3>请求使用的协议:<%=request.getProtocol() %></h3>
    <h3>请求URL:<%=request.getServletPath() %></h3>
    <h3>请求方法:<%=request.getMethod() %></h3>
    <h3>远程地址:<%=request.getRemoteAddr() %></h3>
    <hr size="2" color="red">
</div>
</body>
</html>

展示结果:

 

猜你喜欢

转载自blog.csdn.net/m0_62404144/article/details/124890872