JSP第四次作业

1.

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
   
    
    <title>Homework</title>
    
  </head>
  
  <body>
    <form action="2.jsp" method="post">
    用户名:<input type="text" name="uname" minlength="3" maxlenghth="8"/>只能输入字母或数字,3—8个字符 <br>
    密码:<input type="password" name="upwd" maxlength="12" minlength="6"/>密码长度6-12<br>
    确认密码:<input type="password" name="upawd"><br>
    性别:<input type="radio" name="sex" value="男">男
    <input type="radio" name="sex" value="女">女<br>
    电子邮件地址:<input type="email" name="em" />输入正确的email地址<br>
    出生日期:<input type="text" name="unyear"/>年
    <select name="month">
    <option value="1">一</option>
    <option value="2">二</option>
    <option value="3">三</option>
    <option value="4">四</option>
    
    </select>月
    <select name="day">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select>日<br>
    <input type="submit" value="同意协议条款并提交"/><br>
    <textarea name="bz"rows="5"cols="50">甲乙双方经过友好协商,在公平、诚实、信任、平等合作、互利互惠的基础上,本着为加快中国教育现代化、信息化发展步伐,共同促进教育事业,为广大学校提供优秀的软件产品及完善的售后服务为宗旨,就乙方作为甲方正式授权的金*维2000图书系列软件产品的代理事宜,达成如下协议。</textarea>

    </form>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
   
    
    <title>Homework</title>
    
  </head>
  
  <body>
    
  您注册的信息如下:<br>
  <%
  request.setCharacterEncoding("utf-8");
      String uname=request.getParameter("uname");
      String upwd=request.getParameter("upwd");
      String upawd=request.getParameter("upawd");
      String sex=request.getParameter("sex");
      String em=request.getParameter("em");
      String unyear=request.getParameter("unyear");
      String month=request.getParameter("month");
      String day=request.getParameter("day");
   %>
    <%
    if(upwd.equals(upawd)){%>
    你注册的用户名是:<%=uname %><br>
密码是:<%=upwd %><br>
性别是:<%=sex %><br>
电子邮件地址:<%=em %><br>
出生日期:<%=unyear %>年<%=month %>月<%=day %>日<br>
   <%
    }else{
     %>
    两次不一致
    <% }%>
  </body>
</html>

  

 

 

 

 

2.

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML>
<html>
  <head>
  <title>Homework</title>
  </head>
  <body>
  <form action="2.jsp" method="post">
         求平均值:</br>
         <br>
        姓名:<input type="text" name="uname" /><br>
        <br>
        性别:<input type="radio" name="sex" value ="男"/> 男
         <input type="radio" name="sex" value ="女"/> 女<br>
         <br>
        班级:&nbsp&nbsp&nbsp<select name = "cla">
        <option value="计算机1901">计算机1901</option>
        <option value="计算机1902">计算机1902</option>
        <option value="计算机1903">计算机1903</option>
        <option value="计算机1904">计算机1904</option>
        </select><br>
        <br>
        数学:<input  type="number"  name="math" /></br>
        <br>
        语文:<input  type="number"  name="chin" /></br>
        <br>
        英语:<input  type="number"  name="eng" /></br>
        <br>
        <input type="submit" value="提交"/>
        <input type="reset" value="重置"/>
    </form>
  </body>
</html>

  

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


<!DOCTYPE HTML>
<html>
  <head>
    <title>Homework</title>
  </head>
  
  <body>
     
    <%
       request.setCharacterEncoding("utf-8");
       String uname=request.getParameter("uname");
       String sex=request.getParameter("sex");
       String cla=request.getParameter("cla");
       String math=request.getParameter("math");
       String chin=request.getParameter("chin");
       String eng=request.getParameter("eng");
       double  a=Double.parseDouble(math);
       double  b=Double.parseDouble(chin);
       double  c=Double.parseDouble(eng);
       double equi=(a+b+c)/3;
       out.print("你好!"+cla+"的"+uname+"同学!"+"</br>"+"性别:"+sex+"</br>"+
       "您的各科平均分数是:"+equi);
    %>
  </body>
</html>

  

 

 

 

posted @ 2022-04-10 14:33  MaLD  阅读(30)  评论(0编辑  收藏  举报