JSP第四次上机作业
一、
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>用户注册</title> </head> <body> 用户注册 <a href="#">帮助</a><br> <form action="1.fu.jsp" method="post"> 用户名:<input type="text" value="张三四五六" name="uname">只能输入字母或数字,4-16个字符<br> 密码:<input type="password" value="aaa123" name="upassward">密码长度6-12位<br> 确认密码:<input type="password" value="aaa123" name="upassword"><br> 性别: <input type="radio" value="男" name="sex" checked="default">男 <input type="radio" value="女" name="sex">女<br> 电子邮件地址:<input type="email" value="21738718@11.com" name="email">输入正确的Email地址<br> 出生日期: <select name="year"> <option>1999</option> <option>2000</option> <option>2001</option> </select>年 <select name="month"> <option>二月</option> <option>三月</option> <option>四月</option> </select>月 <select name="day"> <option>5</option> <option>6</option> <option>7</option> </select>日<br> <input type="submit" value="同意以下协议条款并提交" name="agreement"><br> <textarea rows="5" cols="60">一、总则 1.1 用户应当同意本协议的条款并按照页面上的提示完成全部的注册程序。用户在进行注册程序过程中点击“同意”按钮即表示用户雨百度公司达成协议,完全接受本协议项下的全部条款。 1.2 用户注册成功后,百度将给予每个用户一个用户账号及相应的密码,该用户账号和密码由用户负责保管;用户应当对以其用户账号进行的所有活动和事件负法律责任。</textarea> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>Insert title here</title> </head> <body> <h2>您的注册信息如下:</h2> <% request.setCharacterEncoding("utf-8"); String uname=request.getParameter("uname"); String upassword=request.getParameter("upassword"); String sex=request.getParameter("sex"); String email=request.getParameter("email"); String year=request.getParameter("year"); String month=request.getParameter("month"); String day=request.getParameter("day"); String agreement=request.getParameter("agreement"); %> 用户名:<%=uname %> <br> 密码:<%=upassword %> <br> 性别:<%=sex %><br> 电子邮件:<%=email %><br> 出生日期:<%=year %>年<%=month %>月<%=day %>日 </body> </html>
二、
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title></title> </head> <body> 求平均值: <form action="2.rr.jsp" menthod="post"> 姓名:<input type="text" name="uname"><br> 性别: <input type="radio" value="boy" name="sex">boy <input type="radio" value="girl" name="sex">girl<br> 班级: <select name="banji"> <option>1352311</option> <option>1352312</option> <option>1352313</option> </select><br> 语文:<input type="text" value="80" name="chinese"><br> 数学:<input type="text" value="89" name="math"><br> 英语:<input type="text" value="81" name="english"><br> <input type="submit" value="提交" name="sumbit"> <input type="reset" value="重置" name="reset"> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title></title> </head> <body> <% request.setCharacterEncoding("utf-8"); String uname = request.getParameter("uname"); String sex = request.getParameter("sex"); String banji = request.getParameter("banji"); String chinese = request.getParameter("chinese"); String math = request.getParameter("math"); String english = request.getParameter("english"); if (chinese != null && math != null && english != null) { double a = Double.parseDouble(chinese); double b = Double.parseDouble(math); double c = Double.parseDouble(english); double avg = (a + b + c) / 3; %> 您好!<%=banji%>班的<%=uname%>同学! <br>性别:<%=sex%><br>您的各科平均分是:<%=avg%> <% } %> </body> </html>