第六次jsp作业

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form action="info.jsp" method="post">
        <!-- <input type="image" src="images/baidu.png"> -->
        用户名: <input type="text" name="uname" minlength="4" maxlength="16">只能输入字母和数字,4~16个字符<br>
        密码: <input type="password" name="pwd" minlength="6" maxlength="12">密码长度6~12位<br>
        确认密码: <input type="password" name="pwd1" minlength="6" maxlength="12"><br>
        性别: <input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女 <br> 
        电子邮件地址: <input    type="email" name="formmail">输入正确的Email<br> 
        出生日期:<input    type="date" name="year">年 <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">5</option>
            <option value="2">6</option>
            <option value="3">7</option>
            <option value="4">10</option>
        </select>日<br> <input type="submit" value="同意以下协议条款并提交"> <br>
        <textarea rows="5" cols="100">  
            一、总则
         1.用户座当目享本协议的条轮并按院贡西上的提示完感金翻的主册程序。
                          周启连进行注册程南过程中点击“问意技钮即表示用卢与首度公司达取协说,完全控受本苏
                          说项下的全部条常。
         2.用户注册成功后,百度將给予每个用户-个用户帐号及相应的密码,
                           该用户帐号和密码由用户负责保管:用户应当对以其用户帐号进行的所有活动和事件员法律贵Vip。
          </textarea>
    </form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<h1>您注册信息如下:</h1><br>
<%//设置编码
            request.setCharacterEncoding("UTF-8");
            response.setCharacterEncoding("UTF-8");
            //获取请求的数据
            String uname = request.getParameter("uname");
            String pwd = request.getParameter("pwd");
            String pwd1 = request.getParameter("pwd1");
            String sex = request.getParameter("sex");
            String email = request.getParameter("formmail");
            String year = request.getParameter("year");
            String month = request.getParameter("month");
            String day = request.getParameter("day");

            if (pwd.equals(pwd1)) {
                out.print("注册成功" + "<br>");
                out.print("用户名是 :" + uname + "<br>" + "密码是 :" + pwd + "<br>"
                        + "性别 :" + sex + "<br>" + "电子邮件 :" + email + "<br>"
                        + "出生日期 :" + year+"年"+month+"月"+day+"日" + "<br>");
            } else {
                out.print("两次密码不一样!!");
            }%>

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <h2>求平均值:</h2>
    <form action="pingjun.jsp" method="post">
        姓名: <input type="text" name="mxt"> <br> 
        性别: <input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女 <br> 
        班级: <select name="grade">
            <option>-请选择-</option>
            <option>193230303</option>
            <option>193230311</option>
            <option>193230317</option>
            <option>193230324</option>
        </select> <br> 语文: <input type="number" name="Chinese" max="150" min="0">
        <br> 数学: <input type="number" name="math" max="150" min="0">
        <br> 英语: <input type="number" name="English" max="150" min="0">
        <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>
<title>My JSP 'pingjun.jsp' starting page</title>
</head>
<body>
    <%
        //设置编码
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        //获取请求数据
        String grade = request.getParameter("grade");
        String name = request.getParameter("mxt");
        String sex = request.getParameter("sex");
        String Chinese = request.getParameter("Chinese");
        String math = request.getParameter("math");
        String English = request.getParameter("English");
        //将字符串类型转换成数值型
        int a = Integer.parseInt(Chinese);
        int b = Integer.parseInt(math);
        int c = Integer.parseInt(English);
        //求平均值
        double avg = (a + b + c) / 3;
        out.print("你好!" + grade + "班的" + name + "同学<br>" + "性别:" + sex
                + "<br>" + "您的各科平均分是:" + avg);
    %>
</body>
</html>

 

 

 

posted on 2022-04-09 17:36  不顾倾世、只倾她一  阅读(3)  评论(0编辑  收藏  举报

导航