第六周JSP作业
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> <form action="162.jsp" method="post"> 用户名:<input type="text" name="uname" minlength="4" maxlenghth="16"/>只能输入字母或数字,4—6个字符 <br> 密码:<input type="password" name="upwd" maxlength="12" minlength="6"/>密码长度6-12<br> 确认密码:<input type="password" name="upawd"><br> 性别:<input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女<br> 电子邮件地址:<input type="email" name="em" />输入正确的email地址<br> 出生日期:<input type="text" name="unyear"/>年 <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> </select>日<br> <input type="submit" value="同意协议条款并提交"/><br> <textarea name="bz"rows="5"cols="50">空间分布NBAV看见安抚把近几年</textarea> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> 您注册的信息如下:<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 em=request.getParameter("em"); String unyear=request.getParameter("unyear"); String month=request.getParameter("month"); String day=request.getParameter("day"); %> <% if(upwd.equals(upawd)){%> 你注册的用户名是:<%=uname %><br> 密码是:<%=upwd %><br> 性别是:<%=sex %><br> 电子邮件地址:<%=em %><br> 出生日期:<%=unyear %>年<%=month %>月<%=day %>日<br> <% }else{ %> 两次不一致 <% }%> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); %> <!DOCTYPE HTML > <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> 求平均值 <form action="162.jsp" method="post"> <table> <tr> <td>姓名</td> <td><input type="text" name="user"/></td> </tr> <tr> <td>性别</td> <td><input type="radio" name="sex" value="男"/>男</td> <td><input type="radio" name="sex" value="女"/>女</td> </tr> <tr> <td>班级</td> <td><select name="bj"> <option value="1903">1903</option> <option value="1904">1904</option></select> </td> </tr> <tr> <td>语文</td> <td><input type="number" name="ch"/></td> </tr> <tr> <td>数学</td> <td><input type="number" name="ma"/></td> </tr> <tr> <td>英语</td> <td><input type="number" name="en"/></td> </tr> <tr> <td> <input type="submit" value="提交"/></td> <td><input type="reset" value="重置"/></td> </tr> </table> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML > <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> <% request.setCharacterEncoding("utf-8"); String user=request.getParameter("user"); String sex=request.getParameter("sex"); String bj=request.getParameter("bj"); String ch=request.getParameter("ch"); double c=ch==null?-1:Double.parseDouble(ch); String ma=request.getParameter("ma"); double m=ma==null?-1:Double.parseDouble(ma); String en=request.getParameter("en"); double e=en==null?-1:Double.parseDouble(en); double sum=c+m+e; double avg=sum/3; %> 你好!<%=bj %>班的<%=user %>同学!<br> 性别:<%=sex %><br> 您的各科平均分为<%=avg%> </body> </html>