JSP第四周作业

登录功能  用户名zs 密码123 登录成功  

要求 有验证码功能  界面要美观

 index.jsp

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3     String path = request.getContextPath();
 4     String basePath = request.getScheme() + "://"
 5             + request.getServerName() + ":" + request.getServerPort()
 6             + path + "/";
 7 %>
 8 <%
 9      String str=request.getParameter("zh");
10      String pwd=request.getParameter("mm");
11      if(null!=str){
12          if(str.equals("zs")&&pwd.equals("123")){
13              pageContext.forward("dl.jsp");
14          }else{
15              out.println("您输入的账号或密码有误,请确认后重新输入!");
16          }
17      }
18 %> 
19 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
20 <html>
21 <head>
22 <base href="<%=basePath%>">
23 
24 <title>My JSP 'index.jsp' starting page</title>
25 <meta http-equiv="pragma" content="no-cache">
26 <meta http-equiv="cache-control" content="no-cache">
27 <meta http-equiv="expires" content="0">
28 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
29 <meta http-equiv="description" content="This is my page">
30 <!--
31     <link rel="stylesheet" type="text/css" href="styles.css">
32     -->
33 </head>
34 
35  <body>
36     <form action="" method="post"><br>
37     账号:
38     <input type="text" name="zh"><br>
39     密码:
40     <input type="password" name="mm"><br>
41     验证码:
42     <input type="text" name="yz">
43     <img id="yzmtp" src="images/yz.jpg"/>换一张<br>
44     <input type="submit" value="登录" name="dl">
45     </form>
46   </body>
47 </html>

dl.jsp

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 5 %>
 6 
 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 8 <html>
 9   <head>
10     <base href="<%=basePath%>">
11     
12     <title>My JSP 'dl.jsp' starting page</title>
13     
14     <meta http-equiv="pragma" content="no-cache">
15     <meta http-equiv="cache-control" content="no-cache">
16     <meta http-equiv="expires" content="0">    
17     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18     <meta http-equiv="description" content="This is my page">
19     <!--
20     <link rel="stylesheet" type="text/css" href="styles.css">
21     -->
22 
23   </head>
24   
25   <body>
26     欢迎登陆 <br>
27   </body>
28 </html>

 

 

 

 

posted @ 2021-03-26 19:16  潘宇航  阅读(84)  评论(0编辑  收藏  举报