随笔 - 64  文章 - 9  trackbacks - 0
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(6)

我参与的团队

随笔分类(88)

随笔档案(92)

文章分类(142)

文章档案(182)

天基成员

学习园

我的海角

搜索

  •  

积分与排名

  • 积分 - 178742
  • 排名 - 320

最新评论

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 鹏凌 阅读(185) 评论(0)  编辑  收藏 所属分类: Java --j2ee

只有注册用户登录后才能发表评论。


网站导航: