JSP第七周作业

<body bgcolor="#ffccff">
    <%
        double price = 98.78;
    %>
    <p style="font-family: 宋体;font-size: 36;color: blue">
        商品编号A1001,价格8765 
        <a href="my.jsp?id = A1001&price=8765">购买</a><br>
        商品编号A1002,价格<%=price %>
        <a href="my.jsp?id = A1001&price=<%=price%>>">购买</a><br>
    </p>
</body>
<body bgcolor="#eeeeff">
    <p style="font-family: 宋体;font-size: 36;color: blue">
        <%
            String id = request.getParameter("id");
            String price = request.getParameter("price");
        %>
        商品编号:<%= id%><br> 
        商品价格:<%= price%>
        </p>
</body>

 

 

 

<body bgcolor="#ffccff">
    <form action="computer.jsp">
    <p style="font-family: 宋体;font-size: 36;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>
  </body>
<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.print("请输入数字字符");
            }
        %>
    
</body>

 

 

 

 

 

 

 <form action="judge.jsp">
    用户名:<input type="text" name="username"><br>&nbsp;&nbsp;&nbsp;&nbsp;码:<input type="text" name="password"><br>
  <input type="submit" value="登录">
   </form>
 <%
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        if("admin".equals(username) && "12345".equals(password)){
            response.sendRedirect("wel.jsp");
        }
        else if(username == null){
            response.sendRedirect("defeat.jsp");
        }
        else{
            response.sendRedirect("defeat.jsp");
        }
    %>
  <body>
    欢迎你,登录成功!
  </body>
 <body>
    登陆失败!
  </body>

 

 

 

<body>
    <script>

        function lg() {
            if (form.user.value == "") {
                alert("账号不能为空!");
                return;
            }
            if (form.password.value == "") {
                alert("密码不能为空!");
                return;
            }
            if (form.validationCode.value == "") {
                alert("验证码不能为空,请输入验证码");
                form.validationCode.focus();
                return;
            }
            if (form.validationCode.value != form.validationCode1.value) {
                alert("请输入正确的验证码");
                form.validationCode.focus();
                return;
            }

            form.submit();
        }
    </script>

    <%
        int intmethod1 = (int) ((((Math.random()) * 5)) + 1);
        int intmethod2 = (int) ((((Math.random()) * 5)) + 1);
        int intmethod3 = (int) ((((Math.random()) * 5)) + 1);
        int intmethod4 = (int) ((((Math.random()) * 5)) + 1);
        String intsum = intmethod1 + "" + intmethod2 + intmethod3
                + intmethod4;
    %>
    <form action="login.jsp" method="post" name="form">
        用户名:<input type="text" name="user" /> <br>
        密码:<input type="password" name="password" /><br>
         验证码:<input type="text" name="validationCode"
                    onKeyDown="if(event.keyCode==13){form.submit.focus();}" size="6">
                    <input type="button" name="validationCode1" size="1"
                    value="<%=intsum%>"><br>
                是否注册会员:<input type="radio" name="lg" value="" /><input type="radio" name="lg" value="" />否 <br>           
            <input type="submit" value="登录" onclick="yz()" />
<br>   
    </form>
</body>
<body>
  <%
      request.setCharacterEncoding("utf-8");
      
        String user = request.getParameter("user") == null ? "" : request.getParameter("user");
        String password = request.getParameter("password") == null ? "": request.getParameter("password");
        
        if (user.equals(password)) {
            request.getRequestDispatcher("03ok.jsp").forward(request, response);
        } else {
            request.getRequestDispatcher("03no.jsp").forward(request, response);
        }
    %>
  
  
  </body>
  <body>
     <h1>登陆成功</h1>
      <%
    request.setCharacterEncoding("utf-8");
        String lg=request.getParameter("lg");
        if(lg.equals("")){
            out.print("欢迎您注册为会员");
        }
    
        
        
        
         
    %>
  </body>
  <body>
     <h1>登陆失败</h1>
      <% request.setCharacterEncoding("utf-8");%>
  </body>

 

 

<body>
  <%
  String string=request.getParameter("num");
  int i=string==null? -1:Integer.parseInt(string);
  for(int j=0;j<i;j++){
  out.print("欢迎"+"<br>");
  }
  
   %>
  
  
  
  </body>

 

 

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML >
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
    <script>
        function yz() {
            if (form.zh.value == "") {
                alert("用户名不能为空!");
                form.zh.focus();
                return;
            }
            if (form.password.value == "") {
                alert('密码不能为空!');
                form.password.focus();
                return;
            }
            if(form.zh.value==form.password.value){
            form.submit();
            }else{
            alert('登陆失败');
            form.password.focus();
            return;
            }
        }
    </script>

    <form action="index1.jsp" method="post" name="form">
        <table>
            <tr>
                <td>账号</td>
                <td><input type="text" name="zh" />
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" name="password" />
                </td>
            </tr>
            <tr>
                <td><input type="button" value="登录" onclick="yz()" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML >
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<%
String zh=request.getParameter("zh");
 %>

    <form action="index2.jsp" method="post">
        <input type="text" name="name" /> 
        <input type="submit" value="提交" />
        <input type="hidden" name="zh" value="<%=zh %>"/>
    </form>
    
</body>
</html>


<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML >
<html>
  <head>
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  <body>
  <%
  request.setCharacterEncoding("utf-8");
  String zh=request.getParameter("zh");
  String name=request.getParameter("name");
  out.print("用户姓名:"+name+"<br>"+"用户账号:"+zh);
  %>
  
  
  </body>
</html>

 

posted @ 2022-04-17 18:35  不知名的怪物先生  阅读(26)  评论(0)    收藏  举报