第七周作业

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body bgcolor=#ffccff>
    <%
        double p = 98.78;
    %>
    <p>商品编号A1001,价格 8765</p>
    <a href="receive.jsp?id=A1001&price=8765">购买</a>
    <p>商品编号A1002,价格</p>
    <a href="receive.jsp?id=A1002&price=<%=p%>">购买</a>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body bgcolor=#eeeeff>
    <%
        String id = request.getParameter("id");
        String price = request.getParameter("price");
    %>
    <b>商品编号:<%=id%></b>
    <br>
    <b>商品价格:<%=price%></b>
</body>
</html>

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

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

<body bgcolor=cyan>
    <p style="font-family:宋体;font-size:18;color:black">
        <%
            String numberOne = request.getParameter("numberOne");
            String numberTwo = request.getParameter("numberTwo");
            String operator = request.getParameter("operator");
            if (numberOne == null || numberOne.length() == 0) {
                response.sendRedirect("input.jsp");
                return;
            } else if (numberTwo == null || numberTwo.length() == 0) {
                response.sendRedirect("input.jsp");
                return;
            }
            try {
                double a = Double.parseDouble(numberOne);
                double b = Double.parseDouble(numberTwo);
                double r = 0;
                if (operator.equals("+"))
                    r = a + b;
                else if (operator.equals("-"))
                    r = a - b;
                else if (operator.equals("*"))
                    r = a * b;
                else if (operator.equals("/"))
                    r = a / b;
                out.print(a + "" + operator + "" + b + "=" + r);
            } catch (Exception e) {
                out.println("请输入数字字符");
            }
        %>
    
</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 bgcolor=#ffcff>
    <form action="computer.jsp" method=post name=form>
        <p style="font-family:宋体;font-size:18;color:blue">
            输入运算数,选择运算符号:<br>
            <input type=text name="numberOne" size=6 /> 
            <select name="operator">
                <option selected="selected" value="+"><option value="-"><option value="*"><option value="/"></select> 
            <input type=text name="numberTwo" size=6/> <br>
            <input type="submit" name="submit" value="提交" />
    </form>
    </p>
</body>
</html>

3.制作一个登陆表单,输入账号和密码,如果账号密码相同,跳转到“登录成功”页面,否则跳转到“登录失败”页面。(加上JS非空验证)(选做,加验证码)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 
  </head>
   
  <body>
<form action="regist.jsp" method="post">
         
        账号:<input type="text" name="zh" /><br>
       密码: <input type="password" name="upwd" ><br>
        <input type="submit" value="提交"/>
        <input type="reset" value="重置"/>
    </form>
  </body>
</html>
<html>
  <head>
  
<title>My JSP 'index.jsp' starting page</title>
 
  </head>
   
  <body>
 
     <%
     request.setCharacterEncoding("utf-8");
            String zh=request.getParameter("zh");
            String upwd=request.getParameter("upwd");
            if(zh.equals(upwd)){
              response.sendRedirect("trium.jsp");
            }
            else{
                  response.sendRedirect("lose.jsp");
            }
      
         %>
 
     
  </body>
</html>
<html>
  <head>
    
     
    <title>My JSP 'trium.jsp' starting page</title>
     
 
  </head>
   
  <body>
    登录成功! <br>
  </body>
</html>
<html>
  <head>
     
     
    <title>My JSP 'lose.jsp' starting page</title>
     
     
 
  </head>
   
  <body>
       登录失败! <br>
  </body>
</html>


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

<html>
  <head>
   
    <title>在页面1的表单内输人一个数字N,提交,能够在另一个页面打印N个“欢迎”字符串</title>
    
  </head>
  
  <body>
    <form  name="form" action="do7.5.jsp" method="post">
      输入数字N:<input type="text" name="number"><br>
    <input type="submit" value="提交" >    
    </form>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
   
    <title>在页面1的表单内输人一个数字N,提交,能够在另一个页面打印N个“欢迎”字符串</title>
    
  </head>
  
  <body>
    <%
    String number=request.getParameter("number");
    double n=Double.parseDouble(number);
    for(int i=0;i<n;i++){
    out.println("欢迎"+"<br>");
    }
     %>
  </body>
</html>

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <title>shouye.jsp</title>
  </head>
  
  <body>
   <form action="panduan2.jsp" method="post" name="shouye">
           请输入账号:<input name="uname" type="text"/><br/>
           请输入密码:<input name="password" type="password"/><br/>
           <input type="button" value="登录" onclick="denglu()">
      <script type="text/javascript">
         function denglu(){
            if(shouye.uname.value==""){
               alert("账号不能为空!");
               return;
            }
             if(shouye.password.value==""){
               alert("密码不能为空!");
               return;
            }
            shouye.submit();
         }
      </script>
   </form>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <title>panduan2.jsp</title>
  </head>
  
  <body>
   <% 
        request.setCharacterEncoding("utf-8");
        String uname=request.getParameter("uname");
        String password=request.getParameter("password");
        if(uname.equals(password)){
           request.getRequestDispatcher("zhuce.jsp").forward(request, response);
        }else{
           out.print("登陆失败");
        }
    %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>  
    <title>zhuce.jsp</title>
  </head>
  
  <body>
    <%String a=request.getParameter("uname"); %>
  
    <form action="tijiao.jsp" method="post">
          请输入姓名:<input type="text" name="name" /><br/>
          <input type="hidden" name="b" value="<%=a %>" />          
          <input type="submit" name="ok" value="提交"/>
    </form>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>tijiao.jsp</title>
  </head>
  
  <body>
    <% 
    request.setCharacterEncoding("utf-8");
    String name=request.getParameter("name");
    String uname=request.getParameter("b");
    %>
            你的账号为:<%=uname %><br/>
            你的姓名为:<%=name %>
  </body>
</html>

 

 
posted @ 2022-04-16 13:53  五谷鸡爪🥳  阅读(9)  评论(0编辑  收藏  举报