jsp第六次作业
1.
<%@ 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> <head></head> <body> <img src="https://www.baidu.com/img/flexible/logo/pc/result.png" style = "width: 100px;"> <div> <p>用户注册</p> <a>帮助</a> </div> <form action="register.jsp" method="post"> 用户名: <input type="text" name="uname" minlength="4" maxlength="16" />只能输入字母或数字,4-16个字符<br> 密码: <input type="password" name="upwd1" minlength="6" maxlength="12" />密码长度6-12位<br> 确认密码: <input type="password" name="upwd2" minlength="6" maxlength="12" /><br> 性别: <input type="radio" name="sex" value="男" />男 <input type="radio" name="sex" value="女" />女<br> 电子邮件地址: <input type="text" name="email" value="3137601242@qq.com" />输入正确的Email地址<br> 出生日期: <select name="year"> <option value="1999">1999</option> <option value="2000">2000</option> <option value="2001">2001</option> </select>年 <select name="month"> <option value="1">一</option> <option value="2">二</option> <option value="3">三</option> <option value="4">四</option> <option value="5">五</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> </select>日<br> <input type="submit" value="同意以下协议条款并提交" /><br> <textarea rows="5" cols="30">同意以下协议条款并提交同意以下协议条款并提交同意以下协议条款并提交同意以下协议条款并提交同意以下协议条款并提交同意以下协议条款并提交 同意以下协议条款并提交同意以下协议条款并提交</textarea> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% request.setCharacterEncoding("utf-8"); String uname=request.getParameter("uname"); String password1=request.getParameter("upwd1"); String password2=request.getParameter("upwd2"); 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"); if(password1.equals(password2)){%> <b>您注册的信息如下:</b><br> <% out.print("用户名:"+uname+"<br>"+"密码:"+password1+"<br>"+"性别:"+sex+"<br>" +"电子邮件:"+email+"<br>"+"出生日期:"+year+"年"+month+"月"+day+"日"+"<br>"); } else{ out.print("两次密码不一样,注册失败!"); } %> </body> </html>
2.
<%@ 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> <head></head> <body> <form action="main.jsp" method="post"> 求平均值:<br> 姓名:<input type="text" name="uname" /><br> 性别:<input type="radio" name="sex" value="男" />男 <input type="radio" name="sex" value="女" />女<br> 班级:<select name="class"> <option value="计算机1904">计算机1904</option> <option value="计算机1905">计算机1905</option> </select><br> 语文:<input type="text" name="chinese" /><br> 数学:<input type="text" name="math" /><br> 英语:<input type="text" name="english" /><br> <input type="submit" value="提交" /> <input type="reset" value="重置" /> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% request.setCharacterEncoding("utf-8"); String name=request.getParameter("uname"); String sex=request.getParameter("sex"); String cla=request.getParameter("class"); String chinese=request.getParameter("chinese"); String math=request.getParameter("math"); String english=request.getParameter("english"); double x=Double.parseDouble(chinese); double y=Double.parseDouble(math); double z=Double.parseDouble(english); double ave=(x+y+z)/3; out.print("您好!"+cla+"的"+name+"同学!"+"<br>"+"性别:"+sex+"<br>"+"您各科的平均分数是:"+ave); %> </body> </html>