第六周作业
<%@ 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> <meta charset="UTF-8"> <title>百度户注册</title> <style type="text/css"> .one{font-size: 25px;font-weight: bolder;} .two{font-size: 25px;font-weight: bolder;color: blue;} </style> </head> <body> <form action="show.jsp" method="post" name="myform"> <table border="0 " cellspacing="3" cellpadding="4" width="500px"> <tr> <img src="tupian/baidu.jpg" width="250px" height="70px"></img> </tr> <p class="one">注册</p> <tr> <td>用户名 </td> <td><input type="text" name="txtUser" value="" /></td> </tr> <tr> <td>登录密码</td> <td><input type="password" name="" id="" value="" placeholder="请输入密码"/></td> </tr> <tr> <td> 确定密码 </td> <td><input type="password" name="" id="" value="" placeholder="请确定密码" /></td> </tr> <tr> <td> Ealie </td> <td><input type="email" name="email" id="" value="" placeholder="请输入你的Eamli" /></td> </tr> <tr> <td>性别</td> <td> <input type="radio" name="gender" id="" value="男" checked />男 <input type="radio" name="gender" id="" value="女" />女 </td> <tr> <td height="36" width="107">生日:</td> <td width="524"><input name="year" id="year" size="4" value="2000" maxlength="4"> 年 <select name="month"> <option value=1>1</option> <option value=2>2</option> </select> 月 <select name="day"> <option value=1>1</option> <option value=2>2</option> </select> 日</td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="同意以下协议条款并提交"></td> </tr> <tr> <td>简介</td> <td> <textarea rows="5" cols="50">这家伙很懒什么都没有留下</textarea> </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> </head> <body> <h2>您注册的信息如下:</h2> <% request.setCharacterEncoding("utf-8"); String name = request.getParameter("txtUser"); String gender = request.getParameter("gender"); String email = request.getParameter("email"); String year = request.getParameter("year"); String month = request.getParameter("month"); String day = request.getParameter("day"); %> <table> <tr> <td>用户名:</td><td><%=name %></td> </tr> <tr> <td>性别</td><td><%=gender %></td> </tr> <tr> <td>电子邮件:</td><td><%=email %></td> </tr> <tr> <td>出生日期</td><td><%=year %>-<%=month %>-<%=day %></td> </tr> </table> </body> </html>
2:数据输入正确时的显示结果
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>平均值</title> </head> <body> <form action="show.jsp" method="post" name="myform"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <th>求平均值</th> </tr> <tr> <td>姓名:</td> <td><input type="text" name="name" /> </td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="gender" value="男" checked="checked" />男 <input type="radio" name="gender" value="女" />女</td> </tr> <tr> <td>班级:</td> <td><select name="class"> <option value="0">--请选择班级--</option> <option value="1932301">--1932301--</option> <option value="1932302">--1932302--</option> <option value="1932303">--1932303--</option> <option value="1932304">--1932304--</option> </select></td> </tr> <tr> <td>语文:</td> <td><input type="text" name="a" /> </td> </tr> <tr> <td>数学:</td> <td><input type="text" name="b" /> </td> </tr> <tr> <td>英语:</td> <td><input type="text" name="c" /> </td> </tr> <tr> <td><input type="submit" value="提交"><input type="reset" value="重置" /> </td> </tr> </table> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>显示</title> </head> <body> <% request.setCharacterEncoding("utf-8"); String name = request.getParameter("name"); String gender = request.getParameter("gender"); String team = request.getParameter("class"); String yw = request.getParameter("a"); String sx = request.getParameter("b"); String yy = request.getParameter("c"); double a = yw == null ? 0 : Double.parseDouble(yw); double b = sx == null ? 0 : Double.parseDouble(sx); double c = yy == null ? 0 : Double.parseDouble(yy); double avg = (a+b+c)/3; %> 你好!<%=team %>班的<%=name %>同学!<br /> 性别:<%=gender %><br /> 您的各科平均分是:<%=avg %> </body> </html>