JSP第六周作业
1.
<br><%@ 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><%@ 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);<br> %> </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> <base href="<%=basePath%>"> <title>My JSP '3.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> 求平均值 <form action="4.jsp" method="get"> <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="1902">1902</option> <option value="1901">1901</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"%> <% 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> <base href="<%=basePath%>"> <title>My JSP '4.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% request.setCharacterEncoding("utf-8"); String str=request.getParameter("user"); String user=new String(str.getBytes("ISO-8859-1"),"utf-8"); String a=request.getParameter("sex"); String sex=new String(a.getBytes("ISO-8859-1"),"utf-8"); 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>