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

          常用鏈接

          留言簿(6)

          我參與的團隊

          隨筆分類(88)

          隨筆檔案(92)

          文章分類(142)

          文章檔案(182)

          天基成員

          學習園

          我的海角

          搜索

          •  

          積分與排名

          • 積分 - 183507
          • 排名 - 319

          最新評論

          input.jsp

          <%@ page contentType="text/html;Charset=GBK" %>

          <html><body><center>
          <form action="conduct.jsp" method=post>
          <% String username = (String)session.getAttribute("name");
          %>
          用戶:<%= username %>
          <textarea name="message" cols=50 rows=4>
          </textarea>
          <input type="submit" name="submit" value="發送">
          <br>
          <%
           session.setAttribute("name",username);
          %>
          <form>
          </body></html>


          conduct.jsp


          <%@ page contentType="text/html;Charset=GBK" %>
          <%@ page import="java.util.*" %>
          <html><body><center>
          <%!
           Vector v = new Vector();
           ServletContext application;
           synchronized void sendMessage(String message){
            application = getServletContext();
            application.setAttribute("mess",v);
           }
          %>

          <%String username = (String)session.getAttribute("name");
           String message1 = request.getParameter("message");
           String message = username+" : "+"<br>"+message1;
           v.add(message);
           sendMessage(message);
           response.sendRedirect("input.jsp");
          %>

          <%--response.sendRedirect("chatHall.jsp");--%>
          </body></html>



          charHall.jsp

          <%@ page contentType="text/html;Charset=GBK" %>
          <%@ page import="java.util.*" %>

          <html>
          <meta http-equiv="refresh" content="1" url=chatHall.jsp">
          <body>
          <%String username = (String)session.getAttribute("name");
           Vector v = (Vector)application.getAttribute("mess");
           int i = v.size()-1; 
           while(i>0){
            String message = (String)v.elementAt(i);
            out.print(message+"<br>"+"<hr >"+"<br>");
            i--;
           }
          %>
          </body></html>

          chatlist.jsp

          <%@ page contentType="text/html;charset=GBK" %>

          <html><body><center>
          <form action="">

          </form>
          </body></html>

          posted on 2009-09-24 11:11 鵬凌 閱讀(197) 評論(0)  編輯  收藏 所屬分類: Java --j2ee
          主站蜘蛛池模板: 楚雄市| 怀化市| 菏泽市| 台东市| 河西区| 绥德县| 定结县| 汨罗市| 文山县| 洛阳市| 叙永县| 宁武县| 禹州市| 正安县| 巴青县| 科尔| 肃宁县| 大安市| 钟祥市| 渑池县| 廉江市| 三江| 大关县| 宁陵县| 宣城市| 呼伦贝尔市| 平昌县| 山东省| 古田县| 乳源| 武宁县| 罗江县| 五常市| 伊宁市| 千阳县| 洮南市| 安庆市| 韶山市| 乐业县| 灵台县| 武夷山市|