在jsp中实现用户登录,错误跳转(练习4)

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10 <form action="NewFile4.jsp" method="post">
11 账号<input type="text" name="name">
12 密码<input type="password" name="passward">
13 <input type="submit" value="提交">
14 </form>
15 </body>
16 </html>
 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 5 <title>Insert title here</title>
 6 </head>
 7 <body>
 8 <% 
 9 String name=request.getParameter("name");
10 String passward=request.getParameter("passward");
11 %>
12 <%
13 if((name.equals("abcd"))&&(passward.equals("123456")))
14 {
15     out.print("登入成功");
16 }
17 %>
18 <%
19 if(!(name.equals("abcd"))&&(!(passward.equals("123456"))))
20 {
21     
22 %>
23 <jsp:forward page="/lianxi/NewFile5.jsp"></jsp:forward>
24 <%}%>
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10 账户或密码错误,正在等待页面跳转
11 <%response.setHeader("refresh","5;URL=NewFile3.jsp"); %>
12 </body>
13 </html>

 

posted @ 2016-06-25 09:49  明天会更好!!!!  阅读(352)  评论(0)    收藏  举报