隨筆 - 64  文章 - 9  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(6)

          我參與的團隊

          隨筆分類(88)

          隨筆檔案(92)

          文章分類(142)

          文章檔案(182)

          天基成員

          學習園

          我的海角

          搜索

          •  

          積分與排名

          • 積分 - 183507
          • 排名 - 319

          最新評論

          login.html

          <html>
          <body>
          <font size = "16">
          <form action = "chat.jsp" method = "post">
          <center>
          用戶名: <input type = "text" name = "username"><br>
          密碼:<input type = "password" name = "password"><br>
                           <input type = "submit" value = "提交"><br>
          </form>
          </font>
          </body>
          </html>


          chat.jsp

          <%@ page contentType="text/html;Charset=gbk" import="java.util.*"%>
          <%
          String username = request.getParameter("username");
          /*先檢查有沒有hash表*/
          HashMap hs =(HashMap)application.getAttribute("userlist");/*application對象是用服務器創建所有用戶共享,getAttribute檢索與此修改項關聯的屬性。
          返回:
          用于修改的非 null 屬性。*/

          if(hs==null)/*如果沒有,創建一個*/
           hs = new HashMap();
          hs.put(username,username);/*把人加入到hash表*/
          /*把hash表放到appplication中*/
          application.setAttribute("userlist",hs);//將參數添加到application中
          response.sendRedirect("userlist.jsp");//客戶重定向
          %>


          usetlist.jsp

          <%@ page contentType="text/html;Charset=gbk" import="java.util.*"%>
          <meta http-equiv="refresh" content="3; url=userlist.jsp">/*3秒后跳轉到本頁面,用戶端拉 <META HTTP-EQUIV="Refresh" CONTENT="?; URL=URL">(使用端自動更新 )*/
          <html>
          <body>
          <font size="20">
          <%
          out.print("用戶列表如下"+"<Br>");
          HashMap hs= (HashMap)application.getAttribute("userlist");
          Iterator it = hs.keySet().iterator();/*Iterator對集合進行迭代的迭代器,這個Keyset.iterator()迭代器是將hs中的元素按順序讀出來的*/
          while(it.hasNext())//hasNext()如果仍有元素可以迭代,則返回 true。
          {
           Object key = (Object)it.next();//返回迭代的下一個元素。
           Object username =(Object)hs.get(key);
          out.print(username);
          out.print("<br>");
          }
          %>
          </body>
          </html>
          posted on 2009-05-03 11:08 鵬凌 閱讀(105) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 灌南县| 天镇县| 横峰县| 武威市| 惠来县| 山阴县| 平度市| 武安市| 克东县| 阳谷县| 资源县| 报价| 阿坝| 论坛| 仁布县| 广平县| 贞丰县| 丰都县| 平度市| 苏尼特右旗| 宣城市| 土默特左旗| 武川县| 社会| 泸水县| 黄浦区| 白银市| 宜黄县| 改则县| 乌拉特后旗| 西昌市| 延寿县| 确山县| 河间市| 东至县| 含山县| 健康| 香港 | 通辽市| 大连市| 玉山县|