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 '1.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 align="center"> <form action="2.jsp" method="get"> <table style="float: left"> <tr> <td>用户名:<br><br></td> <td><input type="text" name="user" /><br><br> </td> </tr> <tr> <td>密码:<br><br></td> <td><input type="password" name="password" /><br><br> </td> </tr> <tr> <td>确认密码<br><br></td> <td><input type="password" name="password2" /><br><br> </td> </tr> <tr> <td>性别<br><br></td> <td><input type="radio" name="sex" value ="男"/> 男 <input type="radio" name="sex" value ="女"/> 女<br> </td> </tr> <tr> <td>电子邮件<br><br></td> <td><input type="email" name="email"><br><br> </td> </tr> <tr> <td>出生日期<br><br></td> <td><input type="date" name="date"><br><br> </td> </tr> <tr> <td colspan="2" align="right"><input type="submit" value="同意以下协议条款并提交"> </td> </tr> </table> </form> <br> <br> <br> <br> <br> <br> <br><br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <textarea cols="50" rows="10" style="float: left;"> 此处省略..... </textarea> </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> <base href="<%=basePath%>"> <title>My JSP '2.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> <h1>您注册的信息如下</h1> <% request.setCharacterEncoding("utf-8"); String str=request.getParameter("user"); String user=new String(str.getBytes("ISO-8859-1"),"utf-8"); String password=request.getParameter("password"); String a=request.getParameter("sex"); String sex=new String(a.getBytes("ISO-8859-1"),"utf-8"); String email=request.getParameter("email"); String date=request.getParameter("date"); %> 用户名:<%=user %><br> 密码:<%=password %><br> 性别:<%=sex %><br> 电子邮件:<%=email %><br> 出生日期:<%=date %> <br> </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 '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>