程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA綜合教程 >> jsp登錄會話,jsp會話

jsp登錄會話,jsp會話

編輯:JAVA綜合教程

jsp登錄會話,jsp會話


 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>登錄界面</title>
 8 </head>
 9 <body>
10 
11 <form action="test_session2.jsp" method="post"> 
12 <table width="300" height="300" border="0" align="center">
13    <tr height="80" align="center">
14        <td colspan="2"><font size="24">OO登錄</font></td></tr>
15    <tr height="30">
16        <td width="80" align="right">用戶名:</td>                          
17        <td><input type="text" name="name"></td></tr>
18    <tr height="30">
19        <td width="80" align="right"> 密&nbsp;&nbsp;碼:</td>
20        <td> <input type="password" name="password"></td></tr>
21        <tr><td height="40" align="center" colspan="2">
22        <input type="submit" value="登錄"></td></tr>
23  </table>
24 
25 
26 </body>
27 </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>登錄成功</title>
 8 </head>
 9 <body>
10 <% 
11 String name = new String( request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
12 session.setAttribute("name", name);
13 
14 out.println(name + "成功登陸");
15 %>
16 <a href="test_session3.jsp"><br>跳轉</a> 17 </body> 18 </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>會話</title>
 8 </head>
 9 <body>
10 <%
11 String str = "";
12 Object obj = session.getAttribute("name");
13 if(obj != null){
14     str = obj.toString();
15     out.println(str + "已經成功登陸");
16 }else{
17     out.println("會話超時,請重新登錄。");
18 }
19 %>
20 </body>
21 </html>

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved