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

          常用鏈接

          留言簿(6)

          我參與的團隊

          隨筆分類(88)

          隨筆檔案(92)

          文章分類(142)

          文章檔案(182)

          天基成員

          學習園

          我的海角

          搜索

          •  

          積分與排名

          • 積分 - 183418
          • 排名 - 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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 盘山县| 邢台市| 斗六市| 桦南县| 莱西市| 驻马店市| 航空| 昭苏县| 洛隆县| 隆昌县| 惠东县| 白朗县| 翁源县| 绵竹市| 合肥市| 广水市| 邹平县| 定结县| 泸西县| 黄平县| 枞阳县| 灵川县| 林周县| 梧州市| 崇文区| 会理县| 乌拉特中旗| 久治县| 瑞丽市| 台南市| 鹿邑县| 伊金霍洛旗| 兴文县| 永吉县| 南岸区| 闻喜县| 西华县| 义马市| 花垣县| 连山| 宜良县|