JSP第四次作业

1.

 

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3     request.setCharacterEncoding("UTF-8");
 4     response.setCharacterEncoding("UTF-8");
 5 %>
 6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 7 <html>
 8 <head>
 9 <title>My JSP 'login.jsp' starting page</title>
10 </head>
11 <body>
12     <form action="info.jsp" method="post">
13         <!-- <input type="image" src="images/baidu.png"> -->
14         用户名: <input type="text" name="uname" minlength="4" maxlength="16">只能输入字母和数字,4~16个字符<br>
15         密码: <input type="password" name="pwd" minlength="6" maxlength="12">密码长度6~12位<br>
16         确认密码: <input type="password" name="pwd1" minlength="6" maxlength="12"><br>
17         性别: <input type="radio" name="sex" value="男">18              <input type="radio" name="sex" value="女"><br> 
19             电子邮件地址:
20              <input type="email" name="formmail">输入正确的Email<br> 
21              出生日期:<input type="date" name="year">22             <select name="month">
23             <option value="1"></option>
24             <option value="2"></option>
25             <option value="3"></option>
26             <option value="4"></option>
27             <option value="5"></option>
28             <option value="6"></option>
29             <option value="7"></option>
30             <option value="8"></option>
31             <option value="9"></option>
32             <option value="10"></option>
33             <option value="11">十一</option>
34             <option value="12">十二</option>
35         </select><select name="day">
36             <option value="1">5</option>
37             <option value="2">6</option>
38             <option value="3">7</option>
39             <option value="4">8</option>
40         </select><br>
41          <input type="submit" value="同意以下协议条款并提交"> <br>
42         <textarea rows="5" cols="100">
43          一、总则
44          1.用户座当目享本协议的条轮并按院贡西上的提示完感金翻的主册程序。
45          周启连进行注册程南过程中点击“问意技钮即表示用卢与首度公司达取协说,完全控受本苏
46          说项下的全部条常。
47          2.用户注册成功后,百度將给予每个用户-个用户帐号及相应的密码,
48          该用户帐号和密码由用户负责保管:用户应当对以其用户帐号进行的所有活动和事件员法律贵Vip。
49          </textarea>
50     </form>
51 </body>
52 </html>
 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <h1>您注册信息如下:</h1><br>
 3 <%//设置编码
 4             request.setCharacterEncoding("UTF-8");
 5             response.setCharacterEncoding("UTF-8");
 6             //获取请求的数据
 7             String uname = request.getParameter("uname");
 8             String pwd = request.getParameter("pwd");
 9             String pwd1 = request.getParameter("pwd1");
10             String sex = request.getParameter("sex");
11             String email = request.getParameter("formmail");
12             String year = request.getParameter("year");
13             String month = request.getParameter("month");
14             String day = request.getParameter("day");
15 
16             if (pwd.equals(pwd1)) {
17                 out.print("注册成功" + "<br>");
18                 out.print("用户名是 :" + uname + "<br>" + "密码是 :" + pwd + "<br>"
19                         + "性别 :" + sex + "<br>" + "电子邮件 :" + email + "<br>"
20                         + "出生日期 :" + year+""+month+""+day+"" + "<br>");
21             } else {
22                 out.print("两次密码不一样!!");
23             }%>

 

 

 .

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 3 <html>
 4   <head> 
 5     <title>My JSP 'index.jsp' starting page</title>
 6   </head>
 7   <body>
 8   <h2>求平均值:</h2>
 9    <form action="avage.jsp" method="post">
10    姓名:
11    <input type="text" name="mxt">
12    <br>
13      性别:
14    <input type="radio" name="sex" value="男">15    <input type="radio" name="sex" value="女">16    <br>
17      班级:
18    <select name="grade">
19    <option>-请选择-</option>
20    <option>193230216</option>
21    <option>193230217</option>
22    <option>193230218</option>
23    <option>193230219</option>
24    </select>
25    <br>
26      语文:
27    <input type="number" name="Chinese" max="150" min="90">
28    <br>
29      数学:
30    <input type="number" name="math" max="150" min="90">
31    <br>
32      英语:
33    <input type="number" name="English" max="150" min="90" >
34    <br>
35    <input type="submit" value="登录">
36    <input type="reset" value="重置">
37    </form>
38   </body>
39 </html>
 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3     request.setCharacterEncoding("UTF-8");
 4     response.setCharacterEncoding("UTF-8");
 5 %>
 6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 7 <html>
 8 <head>
 9 <title>My JSP 'avage.jsp' starting page</title>
10 </head>
11 <body>
12     <%
13         //设置编码
14         request.setCharacterEncoding("UTF-8");
15         response.setCharacterEncoding("UTF-8");
16         //获取请求数据
17         String grade = request.getParameter("grade");
18         String name = request.getParameter("mxt");
19         String sex = request.getParameter("sex");
20         String Chinese = request.getParameter("Chinese");
21         String math = request.getParameter("math");
22         String English = request.getParameter("English");
23         //将字符串类型转换成数值型
24         int a = Integer.parseInt(Chinese);
25         int b = Integer.parseInt(math);
26         int c = Integer.parseInt(English);
27         //求平均值
28         double avg = (a + b + c) / 3;
29         out.print("你好!" + grade + "班的" + name + "同学<br>" + "性别:" + sex
30                 + "<br>" + "您的各科平均分是:" + avg);
31     %>
32 </body>
33 </html>

 

 

posted @ 2022-04-06 18:42  MXT16  阅读(5)  评论(0编辑  收藏  举报