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> <div style="display: inline; "> <strong style="margin: 0px 400px 0px 0px;">用户注册</strong> </div> <div> <form action="j.jsp" method="post"> <table border="0" cellspacing="10" cellpadding="10"> <tr> <td>用户名:</td> <td><input type="text" name="name" value="sun">只能输入字母或数字,4-16个字符</td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" value="123456">密码长度6-12位</td> </tr> <tr> <td>确认密码:</td> <td><input type="password" value="123456"> </td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="sex" value="男" checked="checked" />男<input type="radio" name="sex" value="女" />女</td> </tr> <tr> <td>电子邮箱地址:</td> <td><input type="email" name="email" value="00000@qq.com"> </td> </tr> <tr> <td>出生日期</td> <td><select name="year"> <option value="1999">1999</option> <option value="2000">2000</option> </select>年 <select name="month"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> </select>月 <select name="day"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> </select>日</td> </tr> <tr> <td></td> <td><input type="submit" value="同意以下协议条款并提交" /></td> </tr> </table> <textarea rows="5" cols="60">协议条款如下: 1.用户应当同意本协议的条款并按照页面上的提示完成全部的注册程序。用户在进行注册程序过程中点击“同意”按钮即表示用户与百度公司达成协议,完全接受本协议项下的全部条款。 2.用户注册成功后, 百度将给予每个用户-个用户帐号及相应的密码,该用户帐号和密码由用户负责保管:用户应当对以其用户帐号进行的所有活动和事件负法律责任。</textarea> </form> </div> </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> <head> </head> <body> <div style="display: inline; "> <strong style="margin: 0px 400px 0px 0px;">用户注册</strong> </div> <div> <form action="j.jsp" method="post"> <table border="0" cellspacing="10" cellpadding="10"> <tr> <td>用户名:</td> <td><input type="text" name="name" value="sun">只能输入字母或数字,4-16个字符</td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" value="123456">密码长度6-12位</td> </tr> <tr> <td>确认密码:</td> <td><input type="password" value="123456"> </td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="sex" value="男" checked="checked" />男<input type="radio" name="sex" value="女" />女</td> </tr> <tr> <td>电子邮箱地址:</td> <td><input type="email" name="email" value="00000@qq.com"> </td> </tr> <tr> <td>出生日期</td> <td><select name="year"> <option value="1999">1999</option> <option value="2000">2000</option> </select>年 <select name="month"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> </select>月 <select name="day"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> </select>日</td> </tr> <tr> <td></td> <td><input type="submit" value="同意以下协议条款并提交" /></td> </tr> </table> <textarea rows="5" cols="60">协议条款如下: 1.用户应当同意本协议的条款并按照页面上的提示完成全部的注册程序。用户在进行注册程序过程中点击“同意”按钮即表示用户与百度公司达成协议,完全接受本协议项下的全部条款。 2.用户注册成功后, 百度将给予每个用户-个用户帐号及相应的密码,该用户帐号和密码由用户负责保管:用户应当对以其用户帐号进行的所有活动和事件负法律责任。</textarea> </form> </div> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% request.setCharacterEncoding("utf-8"); String name = request.getParameter("name"); String password = request.getParameter("password"); String sex = request.getParameter("sex"); String email = request.getParameter("email"); int year=Integer.parseInt(request.getParameter("year")); int month=Integer.parseInt(request.getParameter("month")); int day=Integer.parseInt(request.getParameter("day")); %> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <h2>您注册的信息如下:</h2> 用户名:<%=name %><br> 密码:<%=password %><br> 性别:<%=sex %><br> 电子邮箱:<%=email %><br> 出生日期:<%=year %>年<%=month %>月<%=day %>日 </body> </html>
2.
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <form action="Two.jsp" method="post"> 求平均值:<br> 姓名:<input type="text" name="uname" /><br> 性别:<input type="radio" name="sex" value="男" checked="checked" />男 <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> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </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>