jsp4
1.
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <title>My JSP 'index.jsp' starting page</title> 11 <style type="text/css"> 12 textarea { 13 overflow-y: auto; 14 } 15 .t { 16 float: left; 17 width: 150px; 18 text-align: center; 19 text-align-last: justify; 20 } 21 22 #y { 23 width: 40px; 24 } 25 </style> 26 </head> 27 <body> 28 <img src="img/1.png"> 29 <div style="background-color: #87CEFA ; float: left;width: 35% ;"> 30 <span style="float: left;">用户注册</span><a href="#" 31 style="float: right; ">帮助</a> 32 </div> 33 <form action="index2.jsp" method="post"> 34 <br /> <span class="t">用户名:</span> <input type="text" name="yhm" />只能输入字母或数字,4-16个字符 35 <br /> <span class="t">密码 :</span> <input type="password" name="mm" />密码长度6-12位 36 <br /> <span class="t">确认密码 :</span> <input type="password" name="qrmm" /> 37 <br /> <span class="t">性别:</span> 38 <input type="radio" name="xb" value="男" checked="checked" /> 39 男 <input type="radio" name="xb" value="女" /> 40 女 <br /> <span class="t">电子邮件地址:</span> 41 <input type="email" name="dzyj" />请输入正确的Email地址 <br /> <span 42 class="t">出生日期:</span> <input id="y" type="text" name="year" />年 <select 43 name="month"> 44 <option value="1">一</option> 45 <option value="2">二</option> 46 <option value="3">三</option> 47 <option value="4">四</option> 48 <option value="5">五</option> 49 <option value="6">六</option> 50 <option value="7">七</option> 51 <option value="8">八</option> 52 <option value="9">九</option> 53 <option value="10">十</option> 54 </select>月 <select name="day"> 55 <option value="1">1</option> 56 <option value="2">2</option> 57 <option value="3">3</option> 58 <option value="4">4</option> 59 <option value="5">5</option> 60 <option value="6">6</option> 61 <option value="7">7</option> 62 <option value="8">8</option> 63 <option value="9">9</option> 64 <option value="10">10</option> 65 </select> 日<br /> 66 <input type="submit" value="同意以下协议条款并提交" /> 67 </form> 68 <br> 69 <textarea>条款内容...</textarea> 70 </body> 71 </html>
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <title>My JSP 'index2.jsp' starting page</title> 11 </head> 12 13 <body> 14 <h1>您注册的信息如下</h1> 15 <% 16 request.setCharacterEncoding("utf-8"); 17 String user = request.getParameter("yhm"); 18 String password = request.getParameter("mm"); 19 String sex = request.getParameter("xb"); 20 String email = request.getParameter("dzyj"); 21 String y = request.getParameter("year"); 22 String m = request.getParameter("month"); 23 String d = request.getParameter("day"); 24 %> 25 用户名:<%=user%><br> 密码:<%=password%><br> 性别:<%=sex%><br> 26 电子邮件:<%=email%><br> 出生日期:<%=y%>年<%=m%>月<%=d%>日 27 <br> 28 </body> 29 </html>
2.
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 3 <html> 4 <head> 5 <title></title> 6 </head> 7 8 <body> 9 求平均值: 10 <form action="2.rr.jsp" menthod="post"> 11 姓名:<input type="text" name="uname"><br> 12 性别: <input type="radio" value="boy" name="sex">boy 13 <input type="radio" value="girl" name="sex">girl<br> 14 班级: 15 <select name="banji"> 16 <option>1352311</option> 17 <option>1352312</option> 18 <option>1352313</option> 19 </select><br> 20 语文:<input type="text" value="80" name="chinese"><br> 21 数学:<input type="text" value="89" name="math"><br> 22 英语:<input type="text" value="81" name="english"><br> 23 <input type="submit" value="提交" name="sumbit"> 24 <input type="reset" value="重置" name="reset"> 25 </form> 26 27 </body> 28 </html>
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 3 <html> 4 <head> 5 <title></title> 6 </head> 7 8 <body> 9 <% 10 request.setCharacterEncoding("utf-8"); 11 String uname = request.getParameter("uname"); 12 String sex = request.getParameter("sex"); 13 String banji = request.getParameter("banji"); 14 String chinese = request.getParameter("chinese"); 15 String math = request.getParameter("math"); 16 String english = request.getParameter("english"); 17 if (chinese != null && math != null && english != null) { 18 double a = Double.parseDouble(chinese); 19 double b = Double.parseDouble(math); 20 double c = Double.parseDouble(english); 21 double avg = (a + b + c) / 3; 22 %> 23 您好!<%=banji%>班的<%=uname%>同学! 24 <br>性别:<%=sex%><br>您的各科平均分是:<%=avg%> 25 <% 26 } 27 %> 28 29 </body> 30 </html>