第六周JSP作业

一、

 

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head> 
  <body>
    <form action="doreg.jsp" method="post">
    用户名:<input type="text" name="uname">只能输入字母或数字,4-16个字符<br>
    密码:<input type="password" name="upwd">密码长度6-12位<br>
   确认 密码:<input type="password" name="upwdt"><br>
    性别:
<input type="radio" name="sex" value="男"><input type="radio" name="sex" value="女"><br>
电子邮件地址:<input  type="email" name="uemail" value="2776234108@qq.com">输入正确的Email地址<br>
出生日期:<input  type="data" name="udata" value="2001年-02月-24日">
    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit"  value="同意一下协议并提交"><br>
    <textarea name="text" cols="70" rows="5">协议内容</textarea>
    </form>
  </body>
</html>

 

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>   
  </head>
  <body>
  <%
  request.setCharacterEncoding("utf-8");
      String uname=request.getParameter("uname");
      String upwd1=request.getParameter("upwd"); 
      String upwd2=request.getParameter("upwdt");
      String sex=request.getParameter("sex");
      String uemail=request.getParameter("uemail");
     String udata=request.getParameter("udata");
     
     if(upwd1.equals(upwd2)){
         out.print("注册成功");%><br/>
         <%out.print("用户名是:"+uname+"</br>"+"密码是:"+upwd1+"</br>"+"性别是:"+sex+"</br>"+
             "电子邮件是:"+uemail+"</br>"+"出生日期是:"+udata+"</br>");
     }
     else{
         out.print("两次密码不一样!");
     }
   %>
  </body>
</html>

二、

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head> 
  <body>
    <form action="doreg.jsp" method="post">
        求平均值:</br>
        姓名:<input type="text" name="uname" /><br>
        性别:<input type="radio" name="sex" value ="男"/><input type="radio" name="sex" value ="女"/><br>
        班级:<select name = "les">
        <option value="计算机1901">计算机1901</option>
        <option value="计算机1902">计算机1902</option>
        <option value="计算机1903">计算机1903</option>
        </select><br>
        数学:<input  type="number"  name="mat" /></br>
        语文:<input  type="number"  name="chi" /></br>
        英语:<input  type="number"  name="eng" /></br>
        <input type="submit" value="提交"/>
        <input type="reset" value="重置"/>
        </form>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>   
  </head>
  <body>
  <%
            String uname=request.getParameter("uname");
            String sex=request.getParameter("sex");
            String bj=request.getParameter("les");
            String bir=request.getParameter("bir");
            String math=request.getParameter("mat");
            String chinese=request.getParameter("chi");
            String english=request.getParameter("eng");
            double  a=Double.parseDouble(math);
            double  b=Double.parseDouble(chinese);
            double  c=Double.parseDouble(english);
            double arg=(a+b+c)/3;
            out.print("你好!"+bj+""+uname+"同学!"+"</br>"+"性别:"+sex+"</br>"+
            "您的各科平均分数是:"+arg);
         %>
  </body>
</html>

 

posted @ 2022-04-06 19:28  星星邮寄者  阅读(40)  评论(0编辑  收藏  举报