jsp第四次作业

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

<html>
<body >
 
    <form action="login.jsp" method="post">
        用户名:<input type="text" name="name" value=""><br>
        密码:<input type="password" name="pwd"><br>
        验证码:<img src="number.jsp"/>
          <input type="text" name="code"/>
         
        <input type="submit" name="login" value="登录"><br>
    </form>
</body>
</html>
 
 
 
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    //获取登录的用户名
    String name = request.getParameter("name");
    //获取登录密码
    String pwd = request.getParameter("pwd");
    //判断
 
    if (name.equals("zzs") && pwd.equals("123456"))
        //转发到ok页面
        request.getRequestDispatcher("ok.jsp").forward(request,response);
    else
        //转发到no页面
        request.getRequestDispatcher("no.jsp").forward(request,response);
%>
 
 
 

<%@ 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>
<h1 style="color: red">登录成功</h1>


</body>
</html>

posted @ 2021-03-30 18:03  王志将  阅读(5)  评论(0编辑  收藏  举报