第六次作业
1.
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <form action="MyJsp.jsp" method="post"> <br> 用户名: <input type="text" name="uname"> 只能输入字母或数字,4-16个字符<br> <br> 密 码: <input type="password" name="upwd">(密码长度6-12位)<br> <br> 确认密码: <input type="password" name="upawd"><br> <br> 性别: <input type="radio" name="sex" value="男">boy <input type="radio" name="sex" value="女">girl<br> <br>电子邮箱地址:<input type="email" name="uemail" value=null>输入正确的Email地址<br> <br>出生日期:<input type="text" name="year"/>年 <select name="month"> <option value="1">一</option> <option value="2">二</option> <option value="3">三</option> <option value="4">四</option> <option value="5">五</option> <option value="6">六</option> <option value="7">七</option> <option value="8">八</option> <option value="9">九</option> <option value="10">十</option> <option value="11">十一</option> <option value="12">十二</option> </select>月 <select name="day"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> </select>日<br> <br> <input type="submit" value="同意以下条款并提交" /><br> <textarea rows="10" cols="100" readonly="readonly"> 一、总则 1.1 注册用户同意本协议的全部条款并完成注册程序,才能成为本系统的正式用户。请您仔细阅读本协议,您点击"同意"按钮后即表示完全接受本协议项下的全部条款。 1.2 用户一旦注册,即视为用户确认自己具有享受本站服务的权利能力和行为能力,能够独立承担法律责任。 1.3 在注册和使用本系统时,用户应了解相关法律法规,确知享有的权利和义务;应保证注册时提交的信息合法、真实、准确,并取得相应授权。 </textarea> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <body> <h2>您注册的信息如下</h2> <br> <% request.setCharacterEncoding("utf-8"); String uname=request.getParameter("uname"); String upwd=request.getParameter("upwd"); String upawd=request.getParameter("upawd"); String sex=request.getParameter("sex"); String uemail=request.getParameter("uemail"); String year=request.getParameter("year"); String month=request.getParameter("month"); String day=request.getParameter("day"); %> <% if(upwd.equals(upawd)){%> 你注册的用户名是:<%=uname %><br> 密码是:<%=upwd %><br> 性别是:<%=sex %><br> 电子邮件地址:<%=uemail %><br> 出生日期:<%=year %>年<%=month %>月<%=day %>日<br> <% }else{ %> 密码两次不一致 <% }%> </body> </html>
2.
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> <form action="MyJsp.jsp" method="post"> <h3>求平均值</h3> <br>姓名:<input type="text" name="uname"><br> <br>性别: <input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女<br> <br>班级: <select name="class"> <option value="1901">1901</option>> <option value="1902">1902</option>> <option value="1903">1903</option>> </select><br> <br>语文:<input type="text" name="chinese"><br> <br>数学:<input type="text" name="math"><br> <br>英语:<input type="text" name="english"><br> <br> <input type="submit" value="提交" /> <input type="reset" value="重置" /><br> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'MyJsp.jsp' starting page</title> </head> <body> <% request.setCharacterEncoding("utf-8"); String uname=request.getParameter("uname"); String banji=request.getParameter("class"); String sex=request.getParameter("sex"); String chinese=request.getParameter("chinese"); String math=request.getParameter("math"); String english=request.getParameter("english"); %> <% double y=Double.parseDouble(chinese); int m=Integer.parseInt(chinese); double x=Double.parseDouble(math); double z=Double.parseDouble(english); double agv=(x+y+z)/3; %> 你好!<%=banji %>班的<%=uname %>同学!<br> 性别:<%=sex %><br> 您的各科平均分是:<%=agv %> </body> </html>