JSP第六次作业

1.注册

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>注册</title>

  </head>
  
  <body>
  <div>
  <img src="img/1.png">
  <h3>用户注册</h3>
  <a href="#">帮助</a>
  </div>
  <h2>注册账号</h2>
  <form action="regist.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="2001">2001</option>
        <option id="2002">2002</option>
        <option id="2003">2003</option>
        <option id="2004">2004</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>
        </select><select name="day">
        <option id="item1">1</option>
        <option id="item2">2</option>
        <option id="item3">3</option>
        <option id="item4">4</option>
        </select></td>
        </tr>
        <tr><td><input type="submit" value="同意以下条款并提交"/></td></tr>
</table>
<textarea>同意同意同意同意同意同意同意同意同意同意同意同意</textarea>
</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+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户信息</title>
  </head>
  
  <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>
</html>

 

 

 

 2.求平均分

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>注册</title>

  </head>
  
  <body>
  <div>
   <form action="regist.jsp" >
  姓名: <input type="text" name="name"><br>
  性别: <input type="radio" name="sex" value="男" checked="ok"><input type="radio" name="sex" value="女">女<br>
  班级: <select name=grade>
  <option value="计算机1901">计算机1901
  <option value="计算机1902">计算机1902
  <option value="计算机1903">计算机1903
  <option value="计算机1904">计算机1904
  <option value="计算机1905">计算机1905
  </select>
  <br>
  数学:<input type="text" name="math"><br>
  语文:<input type="text" name="chinese"><br>
  英语:<input type="text" name="english"><br>
   <input type="submit" value="提交">
   <input type="reset" value="重置">
   </form>
   </div>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>平均分</title>
  </head>
  
  <body>
  <h1>求平均分</h1>
  <%
  request.setCharacterEncoding("utf-8");
  String name=request.getParameter("name");
  String grade=request.getParameter("grade");
  String sex=request.getParameter("sex");
  String math=request.getParameter("math");
  String chinese=request.getParameter("chinese");
  String english=request.getParameter("english");
  
  double m=Integer.parseInt(math);
  double c=Integer.parseInt(chinese);
  double e=Integer.parseInt(english);
  double sum=(m+c+e)/3;
   %>
 你好!<%=grade %>班的<%=name %>同学<br>
 性别:<%=sex %><br>
 您的各科平均分为<%=sum %>

  </body>
</html>

 

 

 

posted @ 2022-04-07 15:33  热血青年小刘  阅读(15)  评论(0编辑  收藏  举报