JSP第六周作业

1.


 <body>
  <h2></h2>
  <form action="chuan.jsp" method="post">
    <table>
        <tr>
         <td>用户名  :</td>
         <td><input type="text"name="name"></td>
        </tr>
        <tr>
         <td height="12">密码:</td>
         <td height="12"><input id="password" type="password"name="password"></td>
        </tr>
        <tr>
         <td height="12">确认密码:</td>
         <td height="12"><input id="passwordConfirm" type="password" name="passwordConfirm"></td>
        </tr>
        <tr>
         <td>性别:</td>
         <td>
         <input type="radio" name="sex" value="男" checked="ok"/><input type="radio" name="sex" value="女"/></td>
        </tr>
        <tr>
        <td>电子邮箱地址:</td>
        <td><input type="text" name="email"/>请输入正确的邮箱地址 </td>
        </tr>
        <tr>
        <td>出生日期:</td>
        <td>
        <select name="year">
        <option id="2000">2000</option>
        <option id="2001">2001</option>
        <option id="2002">2002</option>
        <option id="2003">2003</option>
      
        </select><select name="month">
        <option id="1">1</option>
        <option id="2">2</option>
        <option id="3">3</option>
        <option id="4">4</option>
        <option id="5">5</option>
      
        </select><select name="day">
        <option id="item1">1</option>
        <option id="item2">2</option>
        <option id="item3">3</option>
        <option id="item4">4</option>
        <option id="item5">5</option>
        
        </select></td>
        </tr>
        <tr><td><input type="submit" value="同意以下条款并提交"/></td></tr>
</table>
</form>
  </body>

 <body>
  <% request.setCharacterEncoding("utf-8");
  String name= request.getParameter("name");
  String password = request.getParameter("password");
  String sex = request.getParameter("sex");
  String email = request.getParameter("email");
  String year = request.getParameter("year");
  String month = request.getParameter("month");
  String day = request.getParameter("day");
 %>
 用户名:<%=name %><br>
 密码:<%=password %><br>
 性别:<%=sex %><br>
 邮箱:<%=email %><br>
 出生日期:<%=year %><%=month %><%=day %><br>
  </body>

 

 

2.

<body>
  <form action="ch.jsp" method="post">
    <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">1901</option>
                        <option value="1932302">1902</option>
                        <option value="1932303">1903</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>
 <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>

 

posted @ 2022-04-10 18:26  王靖东  阅读(7)  评论(0编辑  收藏  举报