實戰(zhàn)要求:
編寫一個JSP登錄頁面,可輸入用戶名和密碼,提交請求到另一個JSP頁面,該JSP頁面獲取請求的相關(guān)數(shù)據(jù)并顯示出來。請求的相關(guān)數(shù)據(jù)包括用戶輸入的請求數(shù)據(jù)和請求本身的一些信息。
(例如請求使用的協(xié)議getProtocol()、請求的URI request.getServletPath()、請求方法request.getMethod()、遠(yuǎn)程地址request.getRemoteAddr()等)
?7.jsp? 注意:(其中action對應(yīng)的是另一個代碼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>密   碼:<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的顏色可自行設(shè)置--%>
<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>請求使用的協(xié)議:<%=request.getProtocol() %></h3>
<h3>請求URL:<%=request.getServletPath() %></h3>
<h3>請求方法:<%=request.getMethod() %></h3>
<h3>遠(yuǎn)程地址:<%=request.getRemoteAddr() %></h3>
<hr size="2" color="red">
</div>
</body>
</html>
展示結(jié)果:
文章來源:http://www.zghlxwxcb.cn/news/detail-736978.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-736978.html
到了這里,關(guān)于編寫一個JSP登錄頁面,可輸入用戶名和密碼,提交請求到另一個JSP頁面,該JSP頁面獲取請求的相關(guān)數(shù)據(jù)并顯示出來。請求的相關(guān)數(shù)據(jù)包括用戶輸入的請求數(shù)據(jù)和請求本身的一些信息。的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!