第六周作业

1.

 

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

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

 <title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

  </head>

  

 <body>

    <form action="MyJsp.jsp" method="post">

    用户名:<input type="text" name="uname" minlength="4" maxlenghth="16"/>只能输入字母或数字,4—6个字符 <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>

    <option value="5">五</option>

    <option value="6">六</option>

    <option value="7">七</option>

    <option value="8">八</option>

    <option value="9">九</option>

    <option value="10">十</option>

    <option value="11">十一</option>

    <option value="12">十二</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>

    <option value="5">5</option>

    <option value="6">6</option>

<option value="7">7</option>

    <option value="8">8</option>

    <option value="9">9</option>

    <option value="10">10</option>

 

    </select>日<br>

    <input type="submit" value="同意协议条款并提交"/><br>

    <textarea name="bz"rows="5"cols="50">同意</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+"/";

%>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'MyJsp.jsp' starting page</title>

    

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

 

  </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"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'MyJsp1.jsp' starting page</title>

    

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

 

  </head>

  

  <body>

<center>

<form action="MyJsp2.jsp" method="post">

 <br>

 求平均值:

 <br>

 <br>

    姓名:<input type="text" name="uname"> <br>

    <br>

    性别:

  <input type="radio" name="sex" value="男">男

  <input type="radio" name="sex" value="女">女<br>

  <br>

班级:

  <select name="class1" >

  <option value="1">计算机1901</option>

    <option value="2">计算机1902</option>

      <option value="3">计算机1903</option>

    </select><br>

    <br>

语文:

<input type="text" name="yuwen" size=5 /><br>

<br>

数学:

<input type="text" name="shuxue" size=5 /><br>

<br>

英语:

<input type="text" name="yingyu" size=5 /><br>

<br>  

<input type="submit" name="sumbit" value="提交"/>

<input type="submit" name="sumbit1" value="重置"/>     

    </form> 

    </center>

</body>

</html>

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

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'MyJsp2.jsp' starting page</title>

    

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

 

  </head>

  

  <body>

 <%

 request.setCharacterEncoding("utf-8");

 String yuwen=request.getParameter("yuwen");

  String shuxue=request.getParameter("shuxue");

   String yingyu=request.getParameter("yingyu");

   String uname=request.getParameter("uname");

      String sex=request.getParameter("sex");

      String class1=request.getParameter("class1");

    

        int yuwen1=Integer.parseInt(yuwen);

        int shuxue1=Integer.parseInt(shuxue);

        int yingyu1=Integer.parseInt(yingyu);

        double a=(yuwen1+shuxue1+yingyu1)/3.0;   

  %>

 您好!<%=class1 %>班的<%=uname %>同学!<br>

 性别:<%=sex %><br>

 您的各科平均分是:<%=a %>

  

</body>

</html>

 

 

 

 

posted @ 2022-04-10 19:16  计算机1903庞斯文  阅读(30)  评论(0编辑  收藏  举报