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> <base href="<%=basePath%>"> <title>My JSP 'yi.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> <div style="float: left"> <img alt="" src="image/baidu.jpg" width="150px" height="100px"> </div> <br> <div style="background-color: Azure ; float: left; " > 用户注册 <a href="#" >帮助</a> <br> </div> <br> 1.填写信息 2.注册成功并激活空间 <br> <form action="zhuce.jsp" method="post"> 用户名: <input type="text" name="name">只能输入字母或数字,4-16个字符<br/><br/> 密码: <input type="password" name="password1">密码长度6-12位<br/><br/> 确认密码: <input type="password" name="password2"><br/><br/> 性别: <input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女<br/><br/> 电子邮箱: <input type="text" name="Email">请输入正确的Email地址<br/><br/> 出生日期: <input type="text" name="nian">年 <select name="yue"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select>月 <select name="ri"> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select>日 <br/><br/> <input type="submit" name="ok" value="同意以下协议条款并提交"><br/><br/> <textarea name="language" id="tom" rows="3" cols="50"> 一、总则 1.用户应当同意本协议的条款并按照页面上的提示完成全部的注册程序。用户在进行注册程序过程中点击“同意”按钮即表示用户与百度公司达成协议,完全接受本协议项下的全部条款。 2.用户注册成功后, 百度将给予每个用户-个用户帐号及相应的密码,该用户帐号和密码由用户负责保管:用户应当对以其用户帐号进行的所有活动和事件负法律责任。; </textarea> </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 'zhuce.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> <h3>您注册的信息如下:</h3> <% request.setCharacterEncoding("utf-8"); String name=request.getParameter("name"); String password1=request.getParameter("password1"); String sex=request.getParameter("sex"); String Email=request.getParameter("Email"); String nian=request.getParameter("nian"); String yue=request.getParameter("yue"); String ri=request.getParameter("ri"); %> 用户名:<%=name %><br/> 密码:<%=password1 %><br/> 性别:<%=sex %><br/> 电子邮件:<%=Email %><br/> 出生日期:<%=nian %>年<%=yue %>月<%=ri %>日 </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 'MyJsp.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="cz.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 = "les"> <option value="计算机1901">计算机1901</option> <option value="计算机1902">计算机1902</option> <option value="计算机1903">计算机1903</option> </select><br> 数学:<input type="number" name="mat" /></br> 语文:<input type="number" name="chi" /></br> 英语:<input type="number" name="eng" /></br> <input type="submit" value="提交"/> <input type="reset" value="重置"/> </form> </body> </html>
<%@ page language="java" import="java.util.*" contentType="text/html" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <% request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'cz.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> <% String uname=request.getParameter("uname"); String sex=request.getParameter("sex"); String bj=request.getParameter("les"); String bir=request.getParameter("bir"); String math=request.getParameter("mat"); String chinese=request.getParameter("chi"); String english=request.getParameter("eng"); double a=Double.parseDouble(math); double b=Double.parseDouble(chinese); double c=Double.parseDouble(english); double arg=(a+b+c)/3; out.print("你好!"+bj+"的"+uname+"同学!"+"</br>"+"性别:"+sex+"</br>"+ "您的各科平均分数是:"+arg); %> </body> </html>