JSP第六周作业

1.

任务一.jpg

任务一结果.jpg

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <!DOCTYPE html>
 3 <html>
 4 <head>
 5 <meta charset="utf-8">
 6 <title></title>
 7 </head>
 8 <body>
 9     <img style="width: 100px; height: 40px; margin-right: 100px"
10         src="https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png">
11     <div style="display: inline; background-color: aquamarine;">
12         <strong style="margin: 0px 400px 0px 0px;">用户注册</strong>
13         <a href="#">帮助</a>
14     </div>
15     <div>
16         <form action="submit.jsp" method="post">
17             <table border="0" cellspacing="10" cellpadding="10">
18                 <tr>
19                     <td>用户名:</td>
20                     <td><input type="text" name="name" value="张三">只能输入字母或数字,4-16个字符</td>
21                 </tr>
22                 <tr>
23                     <td>密码:</td>
24                     <td><input type="password" name="password" value="123456">密码长度6-12位</td>
25                 </tr>
26                 <tr>
27                     <td>确认密码:</td>
28                     <td><input type="password" value="123456">
29                     </td>
30                 </tr>
31                 <tr>
32                     <td>性别:</td>
33                     <td><input type="radio" name="sex" value="男" checked="checked" />男<input
34                         type="radio" name="sex" value="女" />女</td>
35                 </tr>
36                 <tr>
37                     <td>电子邮箱地址:</td>
38                     <td><input type="email" name="email" value="1234567@qq.com">
39                     </td>
40                 </tr>
41                 <tr>
42                     <td>出生日期</td>
43                     <td><select name="year">
44                             <option value="1999">1999</option>
45                             <option value="2000">2000</option>
46                     </select>年 <select name="month">
47                             <option value="01">01</option>
48                             <option value="02">02</option>
49                     </select>月 <select name="day">
50                             <option value="01">01</option>
51                             <option value="02">02</option>
52                     </select>日</td>
53                 </tr>
54             <tr>
55                         <td></td>
56                         <td><input type="submit" value="同意以下协议条款并提交" /></td>
57                     </tr>
58                 </table>
59                 <textarea rows="5" cols="60">协议条款如下:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd</textarea>
60             </form>
61     </div>
62 </body>
63 </html>
 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%
 3 request.setCharacterEncoding("utf-8");
 4 String name = request.getParameter("name");
 5 String password = request.getParameter("password");
 6 String sex = request.getParameter("sex");
 7 String email = request.getParameter("email");
 8 int year=Integer.parseInt(request.getParameter("year"));
 9 int month=Integer.parseInt(request.getParameter("month"));
10 int day=Integer.parseInt(request.getParameter("day"));
11  %>
12 <!DOCTYPE html>
13 <html>
14 <head>
15 <meta charset="utf-8">
16 <title></title>
17 </head>
18 <body>
19       <h2>您注册的信息如下:</h2>
20       用户名:<%=name %><br>
21       密码:<%=password %><br>
22       性别:<%=sex %><br>
23       电子邮箱:<%=email %><br>
24       出生日期:<%=year %>年<%=month %>月<%=day %>25   </body>
26 </html>

2.

任务二.png

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <!DOCTYPE html>
 3 <html>
 4 <head>
 5 <meta charset="utf-8">
 6 <title></title>
 7 </head>
 8     <form action="avg.jsp" method="post">
 9         求平均值:<br> 姓名:<input type="text" name="uname" /><br> 性别:<input
10             type="radio" name="sex" value="男" checked="checked" />男 <input
11             type="radio" name="sex" value="女" />女<br> 班级:<select
12             name="class">
13             <option value="计算机1904">计算机1904</option>
14             <option value="计算机1905">计算机1905</option>
15         </select><br> 语文:<input type="text" name="chinese" /><br> 数学:<input
16             type="text" name="math" /><br> 英语:<input type="text"
17             name="english" /><br> <input type="submit" value="提交" /> <input
18             type="reset" value="重置" />
19     </form>
20 </html>
 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <!DOCTYPE html>
 3 <html>
 4 <head>
 5 <meta charset="utf-8">
 6 <title></title>
 7 </head>
 8 <body>
 9     <%
10         request.setCharacterEncoding("utf-8");
11         String name = request.getParameter("uname");
12         String sex = request.getParameter("sex");
13         String cla = request.getParameter("class");
14         String chinese = request.getParameter("chinese");
15         String math = request.getParameter("math");
16         String english = request.getParameter("english");
17         double x = Double.parseDouble(chinese);
18         double y = Double.parseDouble(math);
19         double z = Double.parseDouble(english);
20         double ave = (x + y + z) / 3;
21         out.print("您好!" + cla + "的" + name + "同学!" + "<br>" + "性别:" + sex
22                 + "<br>" + "您各科的平均分数是:" + ave);
23     %>
24 </body>
25 </html>

 

posted @ 2022-04-10 12:14  Lwk36  阅读(3)  评论(0编辑  收藏  举报