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 session.invalidate();
12 %>
13 <form action="index2.jsp" method="post">
14 账号:<input type="text" name="un" >
15 <br>
16 密码:<input type="password" name="pw">
17 <br>
18 <input type="submit" value="登录">
19 </form>
20 </body>
21 </html>
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 String un=request.getParameter("un");
12 String pw=request.getParameter("pw");
13 if(un!=null&&pw!=null)
14 {
15 if(un.equals("tom")&&pw.equals("123456"))
16 {
17 session.setAttribute("un", un);
18 session.setMaxInactiveInterval(20);
19 out.print("登录成功......");
20 response.setHeader("refresh", "1;URL=index3.jsp");
21 }
22 else
23 {
24 out.print("账号或密码错误!请重新登录......");
25 response.setHeader("refresh", "1;URL=index1.jsp");
26 }
27 }
28 else
29 {
30 response.sendRedirect("index1.jsp");
31 }
32 %>
33 </body>
34 </html>
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 Object un=session.getAttribute("un");
12 if(un!=null)
13 {
14 out.print("欢迎: "+un.toString());
15 }
16 else
17 {
18 out.print("会话超时!请先登录......");
19 response.setHeader("refresh", "1;URL=index1.jsp");
20 }
21 %>
22 <br>
23 <a href="index1.jsp">退出登录</a>
24 </body>
25 </html>