求jsp聊天室,100分送上 求jsp聊天室,是网页形式的,要求自动更新,不刷新页面,聊天记录能够存储更好。公司要用到这个功能,时间紧。只好找一个改改。发至email:[email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://download.csdn.net/source/289852这是以前学DWR时,做的非常简单的一个..你可以看看,.你要求的功能都有... lanzhengwu 我没有积分了,可不可以给我发个邮件[email protected] -------------------user.jsp---------------------------<%@page contentType="text/html;charset=gbk"%><%--变量 chatroom和retime分别保存用户进入的聊天室的名称和用户在控制窗口中定义的在线用户刷新的时间间隔--%><%String chatroom = new String();chatroom = (String)session.getValue("chatroom");String retime = new String();retime = (String)session.getValue("retime2");%><html><head><title>聊天室</title><meta http-equiv="Content-Type" content="text/html;charset=gb2312"><%--下面这句 HTML 代码是用来定时刷新页面的,URL 为刷新到的页面的路径代码中插入了JSP语句,可以根据要求定义刷新躲时间间隔--%><meta http-equiv="Refresh" content="<%=retime%>;url=user.jsp"></head><body bgcolor="#FFCCCC"><div align="center"> <p><b><font size="3" color="#FF00FF"> <%--根据chatroom的值给出用户所在的聊天室的名称--%> <% if(chatroom.equals("room1")){ %> JSP技术交流 <% } if(chatroom.equals("room2")){ %> JSP光辉未来 <% } if(chatroom.equals("room3")){ %> JSP快速列车 <% } if(chatroom.equals("room4")){ %> 新朋友相识 <% } if(chatroom.equals("room5")){ %> 老朋友相聚 <% } if(chatroom.equals("room6")){ %> 网上情缘 <%}%> </font></b></p> <table width="100" border="0" cellspacing="0" cellpadding="5"> <tr> <td><font size="2" color="#0000FF">在线用户:</font></td> </tr> <%--得到当前聊天室中的在线用户id,并显示出来--%> <% int num; String numtemp = new String(); String temp = new String(); temp = chatroom + "usernum"; numtemp = (String)application.getAttribute(temp); num = Integer.parseInt(numtemp); for(int j=1;j<=num;j++){ String jtemp = new String(); jtemp = jtemp.valueOf(j); temp = chatroom + "user" + jtemp; String usertemp = new String(); usertemp = (String)application.getAttribute(temp); %> <tr> <td> <div align="center"><font size="2" color="#0000FF"><%=usertemp%></font></div> </td> </tr> <%}%> </table> </div></body></html> -----------------------login.jsp----------------------------------------------------<html><head><title>聊天室</title><meta http-equiv="content-type" content="text/html;charset=gb2312"></head><body bgcolor="#CCCCFF"><div align="center"> <p> </p> <p><font size="6" face="Times New Roman,Times,serif"><b><font color="#0000FF">JSP<font face="隶书">聊天室</font></font></b> </p> <form name="login" method="GET" action="login.jsp"> <table width="500" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <p align="center"> </p> <p align="center"><font color="#0000CC">欢迎进入本聊天室,请首先阅读聊天室规则。</font></p> <p align="center"> </p> </td> </tr> <tr> <td> <div align="center"> <p><font color="#0000CC">输入您的聊天代号</font></p> <p><font color="#0000CC"><input type="text" name="txtid" size="20" maxlength="20"> </font></p> </div> </td> </tr> <tr> <td> <div align="center"><font color="#0000CC"> <input type="submit" name="cmdok" value="确定"> <input type="reset" name="cmdreset" value="重置"></font> </div> </td> </tr> <tr align="left" valign="top"> <td height="166"> <p> </p> <p><font color="#FF00FF" size="2">JSP聊天室规则:</font></p> <p><font color="#FF00FF" size="2">1.JSP聊天室是......</font></p> <p><font color="#FF00FF" size="2">2.进入聊天室的用户必须是......</font></p> <p><font color="#FF00FF" size="2">3.在本聊天室聊天时不得......</font></p> </td> </tr> </table> </form></div></body></html> 发错了,不好意思........刚才的login.jsp应该改成 login.html--------------------下面的这个才是 login.jsp------------------Sorry------------------------------------------------------------------login.jsp--------------------------------------------------<%@page contentType="text/html;charset=gb2312"%><%-- 首先取出用户提交的代号名称,保存在变量chatid中--%><% String chatid = new String(); chatid = request.getParameter("txtid");%><%--用flag标记用户输入是否合法,如果合法,则flag为true--%><% boolean flag; flag = true;%><%--判断用户的输入不能为空--%><% if (chatid == null) { chatid = ""; } if (chatid.length()==0){ flag = false; }%><%--比较用户输入的id和目前聊天室中存在的所有的id --%><% for(int i=1;i<=6 && flag;i++){ String itemp = new String(); itemp = itemp.valueOf(i); int num; String numtemp = new String(); String temp = new String(); %> <%-- 从application对象中取出第 i 个聊天室中的总人数 temp变量保存的是application中用于保存第 i 个聊天室总人数的相应变量的名称 --%> <% temp = "room" + itemp + "usernum"; numtemp = (String)application.getAttribute(temp); if(numtemp == null){ numtemp = "0"; application.setAttribute(temp,numtemp); } num = Integer.parseInt(numtemp); %> <%--把用户输入的id 与第 i 个聊天室中的每一个用户id 比较--%> <% for(int j=1;j<=num && flag;j++){ String jtemp = new String (); jtemp = jtemp.valueOf(j); %> <%-- 从application对象中取出第 i 个聊天室中第 j 个用户的 id temp变量保存的是application对象用于保存第 i 个聊天室第 j 个用户 id 的相应的变量名 --%> <% temp = "room" + itemp + "user" + jtemp; String usertemp = new String(); usertemp = (String)application.getAttribute(temp); %> <%--如果用户 id 已经存在, 则设置标志flag为false --%> <% if (usertemp.equalsIgnoreCase(chatid)){ flag = false; } }}%><%--如果flag 为true, 则用户的 id 合法,要对其进行处理定义数组nnn, 用于保存每个聊天室中的人数--%><% int nnn[] = new int[6]; if(flag){ String temproom = new String(); temproom = (String)session.getValue("chatroom"); %> <%-- 判断用户的session 对象 chatroom 是否为空,如果不为空说明用户已经登陆成功过 而且没有正常退出,所以不再为用户保存新的id 这也是为了放置用户重复登陆一个以上的 id --%> <% if(temproom == null){ session.putValue("chatid",chatid); } %> <%--从application对象的相应变量中获取各聊天室的人数并保存与变量数组nnn中--%> <% for(int i=1;i<=6;i++){ String itemp = new String(); itemp = itemp.valueOf(i); int num; String numtemp = new String(); String temp = new String () ; temp = "room" + itemp + "usernum"; numtemp = (String)application.getAttribute(temp); if(numtemp==null){ numtemp = "0"; } num = Integer.parseInt(numtemp); nnn[i-1] = num; } }%><html><head><title>聊天室</title><meta http-equiv="Content-Type" content="text/html;charset=gb2312"></head><body bgcolor="#CCCCFF"><div align="center"> <p> </p> <p><font size="6" face="Times New Roman,Times,serif"><b><font color="#0000ff">JSP<font face="隶书">聊天室 </font></b></font> </p> <p> </p> <% if(flag){ %> <p>用户<%=chatid%>,请选择您想要进入的聊天室</p> <table width="300" border="1" cellspacing="2" cellpadding="5"> <tr align="left" valign="middle"> <td heigth="40" width="150"> <div align="center"><font size="3"><b> <font face="Times New Roman,Times,serif">JSP</font>聊天室</b></font></div> </td> <td heigth="40" width="150"> <div align="center"><font size="3"><b> 普通聊天室</b></font></div> </td> </tr> <tr align="left" valign="top"> <td heigth="30" width="150"> <div align="center"><font size="2"> <a href="JSPchat.jsp?chatroom=1">JSP技术交流(<%=nnn[0]%>)</a></font></div> </td> <td heigth="30" width="150"> <div align="center"><font size="2"> <a href="JSPchat.jsp?chatroom=4">新朋友相识(<%=nnn[3]%>)</a></font></div> </td> </tr> <tr align="left" valign="top"> <td heigth="30" width="150"> <div align="center"><font size="2"> <a href="JSPchat.jsp?chatroom=2">JSP光辉未来(<%=nnn[1]%>)</a></font></div> </td> <td heigth="30" width="150"> <div align="center"><font size="2"> <a href="JSPchat.jsp?chatroom=5">老朋友相聚(<%=nnn[4]%>)</a></font></div> </td> </tr> <tr align="left" valign="top"> <td heigth="30" width="150"> <div align="center"><font size="2"> <a href="JSPchat.jsp?chatroom=3">JSP快速列车(<%=nnn[2]%>)</a></font></div> </td> <td heigth="30" width="150"> <div align="center"><font size="2"> <a href="JSPchat.jsp?chatroom=6">网上情缘(<%=nnn[5]%>)</a></font></div> </td> </tr> </table> <%}else{%> <p>id不能为空,或者这个id 已经有人使用了,请您重新选择.</p> <p><a href="login.htm">回到登陆页面</a></p> <%}%></div></body></html> ------------------------JSPchat.jsp-------------------------------------------<%@page contentType="text/html;charset=gbk"%><%--首先从session对象中获取用户的id ,如果 id 不存在说明用户非正常登陆,程序将提示用户先进行登陆--%><% String chatid = new String() ; chatid = (String)session.getValue("chatid"); if (chatid==null){%>用户不存在,请先登陆.<% }else{ String isin = new String(); isin = (String)session.getValue("chatroom");%><%--isin为null说明用户还没有进入过聊天室,否则为未正常退出有重复进入,需要跳过一些处理--%><% if(isin==null){ %> <%-- 用户进入某一个聊天室,这个聊天室的人数应该加1 ,修改application 对象中保存这个参数的变量数值 --%> <% String chatroom = new String(); chatroom = request.getParameter("chatroom"); chatroom = "room" + chatroom; int num; String numtemp = new String(); String temp = new String(); temp = chatroom + "usernum"; numtemp = (String)application.getAttribute(temp); num = Integer.parseInt(numtemp); num = num + 1; numtemp = numtemp.valueOf(num); application.setAttribute(temp,numtemp); %> <%-- 用application对象的变量保存这个用户的id,以便判断以后登陆用户的id 是否是合法的 --%> <% temp = chatroom + "user" + numtemp; application.setAttribute(temp,chatid); session.putValue("chatroom",chatroom); %> <%--设定该用户的聊天刷新时间和在线用户刷新时间--%> <% session.putValue("retime1","20"); session.putValue("retime2","20"); %> <%-- 将用户登陆的消息加入到 application 变量中用于保存聊天信息的一组变量中 因为某个用户进入聊天室要每个聊天用户一个信息 首先要设定当前最新信息的指针 chatpoint 加 1 . --%> <% temp = chatroom + "chatpoint"; String chatpoint = new String (); chatpoint = (String)application.getAttribute(temp); if (chatpoint==null){ chatpoint = "0"; } int chatpointn; chatpointn = Integer.parseInt(chatpoint); chatpointn = chatpointn + 1; %> <%--如果指针指向超过30,则从1开始,覆盖掉旧的信息--%> <% if (chatpointn==31){ chatpointn = 1; } chatpoint = chatpoint.valueOf(chatpointn); temp = chatroom + "chatpoint"; application.setAttribute(temp,chatpoint); temp = chatroom + "chatword" + chatpoint; %> <%-- 分别保存这个系统信息的内容、显示颜色,设私聊标志为no,说明每个用户都可以看到这个信息 --%> <% application.setAttribute(temp,chatid); temp = chatroom + "chatcolor" + chatpoint; application.setAttribute(temp,"red"); temp = chatroom + "chatprivate" + chatpoint; application.setAttribute(temp,"no"); } %><html><head><title>聊天室</title><meta http-equiv="Content-Type" content="text/html;charset=gb2312"></head><%-- 下面是框架结构,注意在chat.jsp后要加上 "?isret",后面再详细讲解其用途 --%><frameset rows="415,111" frameborder="yes" border="1" framespacing="1" cols="*"> <frameset cols="623,160" frameborder="yes" border="1" framespacing="1" rows="*"> <frame name="chat" src="chat.jsp?isret=yes"> <frame name="user" src="user.jsp" scrolling="no" noresize> </frameset> <frame name="user" src="manage.jsp" scrolling="no" noresize></frameset><noframes><body bgcolor="#FFFFFF"></body></noframes></html><%}%> ----------------------manage.jsp------------------------------------------------<%@page contentType="text/html;charset=gbk"%><%--获取聊天室名称和聊天刷新时间--%><%String chatroom = new String();chatroom = (String)session.getValue("chatroom");String retime1 = new String();retime1 = (String)session.getValue("retime1");String retime2 = new String();retime2 = (String)session.getValue("retime2");%><html><head><title>聊天室</title><meta http-equiv="Content-Type" content="text/html;charset=gb2312"><meta http-equiv="Refresh" content="20;url=manage.jsp"></head><body bgcolor="#FFCCCC"><form method="get" action="chat.jsp" target="chat"><table width="699" border="0" cellspacing="0" cellpadding="5" align="center"> <tr> <td> <p><font size="2" color="#000099"> 聊天内容:<input type="text" name="txtword" size="40" maxlength="40"> 对象: <select name="seluser"> <option value="all" selected>大家</option> <%--设定聊天对象下拉式菜单中的内容--%> <% int num; String numtemp = new String(); String temp = new String(); temp = chatroom + "usernum"; numtemp = (String)application.getAttribute(temp); num = Integer.parseInt(numtemp); for(int j=1;j<=num;j++){ String jtemp = new String(); jtemp = jtemp.valueOf(j); temp = chatroom + "user" + jtemp; String usertemp = new String(); usertemp = (String)application.getAttribute(temp); %> <option value="<%=usertemp%>"><%=usertemp%></option> <%}%> </select> 颜色: <select name="selcolor"> <option value="red">红色</option> <option value="blue">蓝色</option> <option value="green">绿色</option> <option value="yellow">黄色</option> <option value="black" selected>黑色</option> <option value="purple">紫色</option> </select> </font> </p> <p><font size="2" color="#000099">表情: <select name="selface"> <option value="0" selected>无</option> <option value="1">笑嘻嘻</option> <option value="2">微笑</option> <option value="3">爱怜</option> <option value="4">爱慕</option> <option value="5">做鬼脸</option> <option value="6">愤怒</option> <option value="7">生气</option> <option value="8">冷笑</option> <option value="9">嗔怪</option> <option value="10">撒娇</option> </select> 聊天刷新: <select name="selre1"> <option value="<%=retime1%>" selected><%=retime1%></option> <option value="5">5秒</option> <option value="10">10秒</option> <option value="20">20秒</option> <option value="30">30秒</option> <option value="60">60秒</option> </select> 用户刷新: <select name="selre2"> <option value="<%=retime2%>" selected><%=retime2%></option> <option value="5">5秒</option> <option value="10">10秒</option> <option value="20">20秒</option> <option value="30">30秒</option> <option value="60" >60秒</option> </select> <input type="checkbox" name="radprivate" valu="yes"> 私聊 <input type="submit" name="cmdok" value="发送"> <a href="bye.jsp" target="_parent">离开聊天室</a> </font> <font size="2" color="#000099"></font> </p> </td> </tr></table><input type="hidden" name="isret" value="no"></form></body></html> --------------------------chat.jsp------------------------<%@page contentType="text/html;charset=gbk"%><%--用变量chatroom,chatid,chatpoint保存聊天室名称,用户id和当前聊天信息的指针--%><%String chatroom = new String();chatroom = (String)session.getValue("chatroom");String chatid = new String();chatid = (String)session.getValue("chatid");String chatpoint = new String();chatpoint = (String)session.getValue("chatpoint");String temp = new String();temp = chatroom + "chatpoint";chatpoint = (String)application.getAttribute(temp);if(chatpoint==null){ chatpoint = "0";}int chatpointn;chatpointn = Integer.parseInt(chatpoint);String retime1 = new String();String retime2 = new String();%><%--用变量retime1保存聊天信息刷新时间间隔--%><%retime1 = (String)session.getValue("retime1");String chatword = new String();String chatget = new String();String chatgive = new String();String chatcolor = new String();String chatface = new String();String chatprivate = new String();%><%--用isret变量获取提交时isret字段的内容, 如果为no ,则表示是用户提交,要保存用户最新的聊天信息 如果为yes,则表示是页面的自动刷新,不需要保存处理--%><%String isret = new String();isret = request.getParameter("isret");if(isret.equals("no")){ chatword = request.getParameter("txtword"); if(chatword==null || chatword.length()==0){ chatword = "I like JSP."; } chatcolor = request.getParameter("selcolor"); chatface = request.getParameter("selface"); chatgive = chatid; chatget = request.getParameter("seluser"); chatprivate = request.getParameter("radprivate"); if(chatprivate==null){ chatprivate = "no"; }else{ chatprivate = "yes"; } %> <%--设定当前聊天指针加 1 ,如果超过 30 则返回到 1 ,覆盖前面旧的聊天信息--%> <% chatpointn = chatpointn + 1; if(chatpointn == 31){ chatpointn = 1; } chatpoint = chatpoint.valueOf(chatpointn); temp = chatroom + "chatpoint"; application.setAttribute(temp,chatpoint); %> <%--保存用户聊天内容在application对象中--%> <% temp = chatroom + "chatword" + chatpoint; //System.out.println("-----------------*******"); //System.out.println(chatword); //System.out.println("-----------------*******"); application.setAttribute(temp,chatword); %> <%--保存用户聊天内容显示颜色在application对象中--%> <% temp = chatroom + "chatcolor" + chatpoint; application.setAttribute(temp,chatcolor); %> <%--保存用户聊天内容接受者 id 在application对象中--%> <% temp = chatroom + "chatget" + chatpoint; application.setAttribute(temp,chatget); %> <%--保存用户聊天内容发送者 id 在application对象中--%> <% temp = chatroom + "chatgive" + chatpoint; application.setAttribute(temp,chatgive); %> <%--设定用户聊天内容是否为私聊的标志,保存在application对象中--%> <% temp = chatroom + "chatprivate" + chatpoint; application.setAttribute(temp,chatprivate); %> <%--保存用户聊天表情在application对象中--%> <% temp = chatroom + "chatface" + chatpoint; application.setAttribute(temp,chatface); %> <%--保存用户设定的聊天内容刷新速度和在线用户列表刷新速度在session对象中--%> <% retime1 = request.getParameter("selre1"); retime2 = request.getParameter("selre2"); session.putValue("retime1",retime1); session.putValue("retime2",retime2);}%><html><head><title>聊天室</title><meta http-equiv="Content-Type" content="text/html;charset=gb2312"><meta http-equiv="Refresh" content="<%=retime1%>;url=chat.jsp?isret=yes"></head><body bgcolor="#FFCCCC" leftmargin="20" topmargin="20"><table width="550" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <%--显示保存过的所有聊天内容--%> <% if(chatpointn != 0){ %> <%-- 变量j标志着当前要显示的聊天信息的指针,首先从最新的信息开始显示,所以 j 等于chatpoint --%> <% int j; j = chatpointn; //System.out.println(j); //System.out.println("-----------------------------------"); for(int i=1;i<=30 && i<=j;i++){ %> <%--得到以j为当前指针的聊天信息的各部分内容--%> <% String jtemp = new String(); jtemp = jtemp.valueOf(i); temp = chatroom + "chatword" + jtemp; chatword = (String)application.getAttribute(temp); temp = chatroom + "chatcolor" + jtemp; chatcolor = (String)application.getAttribute(temp); temp = chatroom + "chatface" + jtemp; chatface = (String)application.getAttribute(temp); temp = chatroom + "chatprivate" + jtemp; chatprivate = (String)application.getAttribute(temp); temp = chatroom + "chatget" + jtemp; chatget = (String)application.getAttribute(temp); temp = chatroom + "chatgive" + jtemp; chatgive = (String)application.getAttribute(temp); %> <%-- 指针减 1 ,在下一次循环中将显示下一组聊天信息.当指针为 0 时,返回显示末尾记录 --%> <% //j--; //System.out.println(j); //if(j==0){ // j=30; //} %> <%--chatprivate=null表明当前指针位置还没有内容,这种情况只会出现在聊天室刚刚启动application对象的变量中还没保存过聊天内容的时候--%> <% if(!(chatprivate==null)){ %> <%--下面的判断添加如果为真表明当前指针所指向的聊天信息是可以显示的,其中一种为共有信息,另一种为接受者和发送者为当前执行程序的用户的私聊信息--%> <% if(chatprivate.equals("no") || (chatprivate.equals("yes") && (chatgive.equals(chatid) || chatget.equals(chatid) ) ) ) { %> <%--设定显示的颜色和字体大小--%> <font size="2" color="<%=chatcolor%>"> <%--判断是否为系统公告信息,如果是则根据颜色显示不同的公告信息,红色表示是用户进入时的系统公告信息,绿色表明是用户离开时的系统公告信息--%> <% System.out.println(chatget); if(chatprivate.equals("no") && chatget==null){ if(chatcolor.equals("red")){ %> (系统公告)<%=chatword%>进入聊天室. <% } else { chatword = (String)session.getValue("chatid"); System.out.println("$$$$$________________***********"); System.out.println(chatword); System.out.println("$$$$$________________***********"); %> (系统公告)<%=chatword%>离开聊天室. <% } } else { %> <%--如果是私聊信息要加上"私聊" 字样--%> <% if(chatprivate.equals("yes")){ %> (私聊) <% } %> <%--下面分别显示聊天的发送者,接受者,表情和聊天的内容--%> <% out.println(chatgive); %> 对 <% if(chatget.equals("all")){ %> 大家 <% } else { out.println(chatget); } %> <% int nn; nn = Integer.parseInt(chatface); switch(nn){ case 1: %> 笑嘻嘻的 <% break; case 2: %> 微笑着 <% break; case 3: %> 充满拎爱的 <% break; case 4: %> 含情脉脉的 <% break; case 5: %> 做了个鬼脸 <% break; case 6: %> 怒气冲冲的 <% break; case 7: %> 有些生气的 <% break; case 8: %> 冷笑着 <% break; case 9: %> 嗔怪的 <% break; case 10: %> 撒娇的 <% } %> 说: <% out.println(chatword); } %> </font> <br><br> <% } } }} %> </td> </tr></table></html> ---------------------bye.jsp------------------------------------------------<%@page contentType="text/html;charset=gbk"%><%String chatid = new String();chatid = (String)session.getValue("chatid");//System.out.println("--------------------");//System.out.println(chatid);//System.out.println("--------------------");String chatroom = new String();chatroom = (String)session.getValue("chatroom");if(!(chatroom==null)){%><%--用于保存用户所在聊天室总人数的 application 对象变量的数值减 1 --%><%int num;String numtemp = new String();String temp = new String();temp = chatroom + "usernum";numtemp = (String)application.getAttribute(temp);num = Integer.parseInt(numtemp);num = num - 1;numtemp = numtemp.valueOf(num);application.setAttribute(temp,numtemp);%><%--保存用户离开的系统公告信息--%><%temp = chatroom + "chatpoint";String chatpoint = new String();chatpoint = (String)application.getAttribute(temp);int chatpointn ;chatpointn = Integer.parseInt(chatpoint);chatpointn = chatpointn + 1;if(chatpointn == 31){ chatpointn = 1;}chatpoint = chatpoint.valueOf(chatpointn);temp = chatroom + "chatpoint";application.setAttribute(temp,chatpoint);temp = chatroom + "charword" + chatpoint;application.setAttribute(temp,chatid);temp = chatroom + "chatcolor" + chatpoint;application.setAttribute(temp,"blue");temp = chatroom + "chatprivate" + chatpoint;application.setAttribute(temp,"no");session.invalidate();%><html><head><title>聊天室</title><meta http-equiv="Content-Type" content="text/html;charset=gb2312"></head><body bgcolor="#9999ff"><div align="center"> <p> </p> <p> </p> <p><b>您已经成功退出聊天室</b></p> <p><b>欢迎您常来</b></p> <p> </p> <p><a href="login.htm">重新登陆</a></p></div></body></html><%} else {%>您还没有登陆<%} %> 谢谢大家关注,怕都不是我想要的。我需要的是即时消息的,web形式的,要求性能强的,可以承担上万人同时在线的聊天室,可以对聊天内容记录。代码要是mvc的,最好是比软成熟的开源产品。因为要集成到我们的系统中使用。看open-open中的产品http://www.open-open.com/52.htm哪个用得更广? application对像到最后聊天内容清空了吗?如没清,那服务器不重启,那聊数据量太大了。 就这些jsp的界面吗?还有什么吗?能不能提供一点后台代码 聊天室的源码拿来用用先!中文乱码哇,非得把get改post 然后setUTF-8 处理页面获取不到ID 得到的是为null MySQL Limit最后一页的问题 java flex的问题,急!急!急!急!急!,求救啊! 问个java对象的问题 运行项目时tomcat报错: 谁帮我看下这个 js 树型菜单代码 ? 关于smartupload的编译问题 使用什么工具写JSP,,来者有分!! 页面上的错误,急求解 请问在SUN的J2EE上面如何联接SQL SERVER进行EJB开发 Struts2中想通过JS来控制输入等标签的隐藏和显示,请问怎么搞? 首次使用Heritrix,为什么没有找到mirror目录
这是以前学DWR时,做的非常简单的一个..你可以看看,.
你要求的功能都有...
我没有积分了,可不可以给我发个邮件
[email protected]
<%@page contentType="text/html;charset=gbk"%><%--变量 chatroom和retime分别保存用户进入的聊天室的名称和用户在控制窗口中定义的在线用户刷新的时间间隔--%>
<%
String chatroom = new String();
chatroom = (String)session.getValue("chatroom");
String retime = new String();
retime = (String)session.getValue("retime2");
%><html>
<head>
<title>聊天室</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<%--
下面这句 HTML 代码是用来定时刷新页面的,URL 为刷新到的页面的路径
代码中插入了JSP语句,可以根据要求定义刷新躲时间间隔
--%>
<meta http-equiv="Refresh" content="<%=retime%>;url=user.jsp"></head><body bgcolor="#FFCCCC">
<div align="center">
<p><b><font size="3" color="#FF00FF">
<%--根据chatroom的值给出用户所在的聊天室的名称--%>
<%
if(chatroom.equals("room1")){
%>
JSP技术交流
<%
}
if(chatroom.equals("room2")){
%>
JSP光辉未来
<%
}
if(chatroom.equals("room3")){
%>
JSP快速列车
<%
}
if(chatroom.equals("room4")){
%>
新朋友相识
<%
}
if(chatroom.equals("room5")){
%>
老朋友相聚
<%
}
if(chatroom.equals("room6")){
%>
网上情缘
<%}%>
</font></b></p>
<table width="100" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><font size="2" color="#0000FF">在线用户:</font></td>
</tr>
<%--得到当前聊天室中的在线用户id,并显示出来--%>
<%
int num;
String numtemp = new String();
String temp = new String();
temp = chatroom + "usernum";
numtemp = (String)application.getAttribute(temp);
num = Integer.parseInt(numtemp);
for(int j=1;j<=num;j++){
String jtemp = new String();
jtemp = jtemp.valueOf(j);
temp = chatroom + "user" + jtemp;
String usertemp = new String();
usertemp = (String)application.getAttribute(temp);
%>
<tr>
<td>
<div align="center"><font size="2" color="#0000FF"><%=usertemp%></font></div>
</td>
</tr>
<%}%>
</table>
</div>
</body>
</html>
<html>
<head>
<title>聊天室</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head><body bgcolor="#CCCCFF">
<div align="center">
<p> </p>
<p><font size="6" face="Times New Roman,Times,serif"><b><font color="#0000FF">JSP<font face="隶书">聊天室</font></font></b>
</p>
<form name="login" method="GET" action="login.jsp">
<table width="500" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<p align="center"> </p>
<p align="center"><font color="#0000CC">欢迎进入本聊天室,请首先阅读聊天室规则。</font></p>
<p align="center"> </p>
</td>
</tr>
<tr>
<td>
<div align="center">
<p><font color="#0000CC">输入您的聊天代号</font></p>
<p><font color="#0000CC"><input type="text" name="txtid" size="20" maxlength="20">
</font></p>
</div>
</td>
</tr>
<tr>
<td>
<div align="center"><font color="#0000CC">
<input type="submit" name="cmdok" value="确定">
<input type="reset" name="cmdreset" value="重置"></font>
</div>
</td>
</tr>
<tr align="left" valign="top">
<td height="166">
<p> </p>
<p><font color="#FF00FF" size="2">JSP聊天室规则:</font></p>
<p><font color="#FF00FF" size="2">1.JSP聊天室是......</font></p>
<p><font color="#FF00FF" size="2">2.进入聊天室的用户必须是......</font></p>
<p><font color="#FF00FF" size="2">3.在本聊天室聊天时不得......</font></p>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
下面的这个才是 login.jsp------------------Sorry------------------------------------------------------------------login.jsp--------------------------------------------------
<%@page contentType="text/html;charset=gb2312"%>
<%-- 首先取出用户提交的代号名称,保存在变量chatid中--%>
<%
String chatid = new String();
chatid = request.getParameter("txtid");
%>
<%--用flag标记用户输入是否合法,如果合法,则flag为true--%>
<%
boolean flag;
flag = true;
%>
<%--判断用户的输入不能为空--%>
<%
if (chatid == null) {
chatid = "";
}
if (chatid.length()==0){
flag = false;
}
%>
<%--比较用户输入的id和目前聊天室中存在的所有的id --%>
<%
for(int i=1;i<=6 && flag;i++){
String itemp = new String();
itemp = itemp.valueOf(i);
int num;
String numtemp = new String();
String temp = new String();
%>
<%--
从application对象中取出第 i 个聊天室中的总人数
temp变量保存的是application中用于保存第 i 个聊天室总人数的相应变量的名称
--%>
<%
temp = "room" + itemp + "usernum";
numtemp = (String)application.getAttribute(temp);
if(numtemp == null){
numtemp = "0";
application.setAttribute(temp,numtemp);
}
num = Integer.parseInt(numtemp);
%>
<%--把用户输入的id 与第 i 个聊天室中的每一个用户id 比较--%>
<%
for(int j=1;j<=num && flag;j++){
String jtemp = new String ();
jtemp = jtemp.valueOf(j);
%>
<%--
从application对象中取出第 i 个聊天室中第 j 个用户的 id
temp变量保存的是application对象用于保存第 i 个聊天室第 j 个用户 id 的相应的变量名
--%>
<%
temp = "room" + itemp + "user" + jtemp;
String usertemp = new String();
usertemp = (String)application.getAttribute(temp);
%>
<%--如果用户 id 已经存在, 则设置标志flag为false --%>
<%
if (usertemp.equalsIgnoreCase(chatid)){
flag = false;
}
}
}
%>
<%--
如果flag 为true, 则用户的 id 合法,要对其进行处理
定义数组nnn, 用于保存每个聊天室中的人数
--%>
<%
int nnn[] = new int[6];
if(flag){
String temproom = new String();
temproom = (String)session.getValue("chatroom");
%>
<%--
判断用户的session 对象 chatroom 是否为空,如果不为空说明用户已经登陆成功过
而且没有正常退出,所以不再为用户保存新的id
这也是为了放置用户重复登陆一个以上的 id
--%>
<%
if(temproom == null){
session.putValue("chatid",chatid);
}
%>
<%--从application对象的相应变量中获取各聊天室的人数并保存与变量数组nnn中--%>
<%
for(int i=1;i<=6;i++){
String itemp = new String();
itemp = itemp.valueOf(i);
int num;
String numtemp = new String();
String temp = new String () ;
temp = "room" + itemp + "usernum";
numtemp = (String)application.getAttribute(temp);
if(numtemp==null){
numtemp = "0";
}
num = Integer.parseInt(numtemp);
nnn[i-1] = num;
}
}
%><html>
<head>
<title>聊天室</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<body bgcolor="#CCCCFF">
<div align="center">
<p> </p>
<p><font size="6" face="Times New Roman,Times,serif"><b><font color="#0000ff">JSP<font face="隶书">聊天室 </font></b></font>
</p>
<p> </p>
<%
if(flag){
%>
<p>用户<%=chatid%>,请选择您想要进入的聊天室</p>
<table width="300" border="1" cellspacing="2" cellpadding="5">
<tr align="left" valign="middle">
<td heigth="40" width="150">
<div align="center"><font size="3"><b>
<font face="Times New Roman,Times,serif">JSP</font>聊天室</b></font></div>
</td>
<td heigth="40" width="150">
<div align="center"><font size="3"><b>
普通聊天室</b></font></div>
</td>
</tr>
<tr align="left" valign="top">
<td heigth="30" width="150">
<div align="center"><font size="2">
<a href="JSPchat.jsp?chatroom=1">JSP技术交流(<%=nnn[0]%>)</a></font></div>
</td>
<td heigth="30" width="150">
<div align="center"><font size="2">
<a href="JSPchat.jsp?chatroom=4">新朋友相识(<%=nnn[3]%>)</a></font></div>
</td>
</tr>
<tr align="left" valign="top">
<td heigth="30" width="150">
<div align="center"><font size="2">
<a href="JSPchat.jsp?chatroom=2">JSP光辉未来(<%=nnn[1]%>)</a></font></div>
</td>
<td heigth="30" width="150">
<div align="center"><font size="2">
<a href="JSPchat.jsp?chatroom=5">老朋友相聚(<%=nnn[4]%>)</a></font></div>
</td>
</tr>
<tr align="left" valign="top">
<td heigth="30" width="150">
<div align="center"><font size="2">
<a href="JSPchat.jsp?chatroom=3">JSP快速列车(<%=nnn[2]%>)</a></font></div>
</td>
<td heigth="30" width="150">
<div align="center"><font size="2">
<a href="JSPchat.jsp?chatroom=6">网上情缘(<%=nnn[5]%>)</a></font></div>
</td>
</tr>
</table>
<%}else{%>
<p>id不能为空,或者这个id 已经有人使用了,请您重新选择.</p>
<p><a href="login.htm">回到登陆页面</a></p>
<%}%>
</div>
</body>
</html>
<%@page contentType="text/html;charset=gbk"%>
<%--
首先从session对象中获取用户的id ,如果 id 不存在说明用户非正常登陆,程序将提示用户先进行登陆
--%>
<%
String chatid = new String() ;
chatid = (String)session.getValue("chatid");
if (chatid==null){
%>
用户不存在,请先登陆.
<%
}else{
String isin = new String();
isin = (String)session.getValue("chatroom");
%>
<%--isin为null说明用户还没有进入过聊天室,否则为未正常退出有重复进入,需要跳过一些处理--%>
<%
if(isin==null){
%>
<%--
用户进入某一个聊天室,这个聊天室的人数应该加1 ,修改application 对象中保存这个参数的变量数值
--%>
<%
String chatroom = new String();
chatroom = request.getParameter("chatroom");
chatroom = "room" + chatroom;
int num;
String numtemp = new String();
String temp = new String();
temp = chatroom + "usernum";
numtemp = (String)application.getAttribute(temp);
num = Integer.parseInt(numtemp);
num = num + 1;
numtemp = numtemp.valueOf(num);
application.setAttribute(temp,numtemp);
%>
<%--
用application对象的变量保存这个用户的id,以便判断以后登陆用户的id 是否是合法的
--%>
<%
temp = chatroom + "user" + numtemp;
application.setAttribute(temp,chatid);
session.putValue("chatroom",chatroom);
%>
<%--设定该用户的聊天刷新时间和在线用户刷新时间--%>
<%
session.putValue("retime1","20");
session.putValue("retime2","20");
%>
<%--
将用户登陆的消息加入到 application 变量中用于保存聊天信息的一组变量中
因为某个用户进入聊天室要每个聊天用户一个信息
首先要设定当前最新信息的指针 chatpoint 加 1 .
--%>
<%
temp = chatroom + "chatpoint";
String chatpoint = new String ();
chatpoint = (String)application.getAttribute(temp);
if (chatpoint==null){
chatpoint = "0";
}
int chatpointn;
chatpointn = Integer.parseInt(chatpoint);
chatpointn = chatpointn + 1;
%>
<%--如果指针指向超过30,则从1开始,覆盖掉旧的信息--%>
<%
if (chatpointn==31){
chatpointn = 1;
}
chatpoint = chatpoint.valueOf(chatpointn);
temp = chatroom + "chatpoint";
application.setAttribute(temp,chatpoint);
temp = chatroom + "chatword" + chatpoint;
%>
<%--
分别保存这个系统信息的内容、显示颜色,设私聊标志为no,说明每个用户都可以看到这个信息
--%>
<%
application.setAttribute(temp,chatid);
temp = chatroom + "chatcolor" + chatpoint;
application.setAttribute(temp,"red");
temp = chatroom + "chatprivate" + chatpoint;
application.setAttribute(temp,"no");
}
%>
<html>
<head>
<title>聊天室</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<%--
下面是框架结构,注意在chat.jsp后要加上 "?isret",后面再详细讲解其用途
--%>
<frameset rows="415,111" frameborder="yes" border="1" framespacing="1" cols="*">
<frameset cols="623,160" frameborder="yes" border="1" framespacing="1" rows="*">
<frame name="chat" src="chat.jsp?isret=yes">
<frame name="user" src="user.jsp" scrolling="no" noresize>
</frameset>
<frame name="user" src="manage.jsp" scrolling="no" noresize>
</frameset>
<noframes>
<body bgcolor="#FFFFFF">
</body>
</noframes>
</html>
<%}%>
<%@page contentType="text/html;charset=gbk"%><%--获取聊天室名称和聊天刷新时间--%>
<%
String chatroom = new String();
chatroom = (String)session.getValue("chatroom");
String retime1 = new String();
retime1 = (String)session.getValue("retime1");
String retime2 = new String();
retime2 = (String)session.getValue("retime2");
%><html>
<head>
<title>聊天室</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta http-equiv="Refresh" content="20;url=manage.jsp">
</head><body bgcolor="#FFCCCC">
<form method="get" action="chat.jsp" target="chat">
<table width="699" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td>
<p><font size="2" color="#000099">
聊天内容:<input type="text" name="txtword" size="40" maxlength="40">
对象:
<select name="seluser">
<option value="all" selected>大家</option>
<%--设定聊天对象下拉式菜单中的内容--%>
<%
int num;
String numtemp = new String();
String temp = new String();
temp = chatroom + "usernum";
numtemp = (String)application.getAttribute(temp);
num = Integer.parseInt(numtemp);
for(int j=1;j<=num;j++){
String jtemp = new String();
jtemp = jtemp.valueOf(j);
temp = chatroom + "user" + jtemp;
String usertemp = new String();
usertemp = (String)application.getAttribute(temp);
%>
<option value="<%=usertemp%>"><%=usertemp%></option>
<%}%>
</select>
颜色:
<select name="selcolor">
<option value="red">红色</option>
<option value="blue">蓝色</option>
<option value="green">绿色</option>
<option value="yellow">黄色</option>
<option value="black" selected>黑色</option>
<option value="purple">紫色</option>
</select>
</font>
</p>
<p><font size="2" color="#000099">表情:
<select name="selface">
<option value="0" selected>无</option>
<option value="1">笑嘻嘻</option>
<option value="2">微笑</option>
<option value="3">爱怜</option>
<option value="4">爱慕</option>
<option value="5">做鬼脸</option>
<option value="6">愤怒</option>
<option value="7">生气</option>
<option value="8">冷笑</option>
<option value="9">嗔怪</option>
<option value="10">撒娇</option>
</select>
聊天刷新:
<select name="selre1">
<option value="<%=retime1%>" selected><%=retime1%></option>
<option value="5">5秒</option>
<option value="10">10秒</option>
<option value="20">20秒</option>
<option value="30">30秒</option>
<option value="60">60秒</option>
</select>
用户刷新:
<select name="selre2">
<option value="<%=retime2%>" selected><%=retime2%></option>
<option value="5">5秒</option>
<option value="10">10秒</option>
<option value="20">20秒</option>
<option value="30">30秒</option>
<option value="60" >60秒</option>
</select>
<input type="checkbox" name="radprivate" valu="yes">
私聊
<input type="submit" name="cmdok" value="发送">
<a href="bye.jsp" target="_parent">离开聊天室</a>
</font>
<font size="2" color="#000099"></font>
</p>
</td>
</tr>
</table>
<input type="hidden" name="isret" value="no">
</form>
</body>
</html>
<%@page contentType="text/html;charset=gbk"%><%--用变量chatroom,chatid,chatpoint保存聊天室名称,用户id和当前聊天信息的指针--%>
<%
String chatroom = new String();
chatroom = (String)session.getValue("chatroom");
String chatid = new String();
chatid = (String)session.getValue("chatid");
String chatpoint = new String();
chatpoint = (String)session.getValue("chatpoint");
String temp = new String();
temp = chatroom + "chatpoint";
chatpoint = (String)application.getAttribute(temp);
if(chatpoint==null){
chatpoint = "0";
}
int chatpointn;
chatpointn = Integer.parseInt(chatpoint);
String retime1 = new String();
String retime2 = new String();
%>
<%--用变量retime1保存聊天信息刷新时间间隔--%>
<%
retime1 = (String)session.getValue("retime1");
String chatword = new String();
String chatget = new String();
String chatgive = new String();
String chatcolor = new String();
String chatface = new String();
String chatprivate = new String();
%>
<%--用isret变量获取提交时isret字段的内容,
如果为no ,则表示是用户提交,要保存用户最新的聊天信息
如果为yes,则表示是页面的自动刷新,不需要保存处理
--%>
<%
String isret = new String();
isret = request.getParameter("isret");
if(isret.equals("no")){
chatword = request.getParameter("txtword");
if(chatword==null || chatword.length()==0){
chatword = "I like JSP.";
}
chatcolor = request.getParameter("selcolor");
chatface = request.getParameter("selface");
chatgive = chatid;
chatget = request.getParameter("seluser");
chatprivate = request.getParameter("radprivate");
if(chatprivate==null){
chatprivate = "no";
}else{
chatprivate = "yes";
}
%>
<%--设定当前聊天指针加 1 ,如果超过 30 则返回到 1 ,覆盖前面旧的聊天信息--%>
<%
chatpointn = chatpointn + 1;
if(chatpointn == 31){
chatpointn = 1;
}
chatpoint = chatpoint.valueOf(chatpointn);
temp = chatroom + "chatpoint";
application.setAttribute(temp,chatpoint);
%>
<%--保存用户聊天内容在application对象中--%>
<%
temp = chatroom + "chatword" + chatpoint;
//System.out.println("-----------------*******");
//System.out.println(chatword);
//System.out.println("-----------------*******");
application.setAttribute(temp,chatword);
%>
<%--保存用户聊天内容显示颜色在application对象中--%>
<%
temp = chatroom + "chatcolor" + chatpoint;
application.setAttribute(temp,chatcolor);
%>
<%--保存用户聊天内容接受者 id 在application对象中--%>
<%
temp = chatroom + "chatget" + chatpoint;
application.setAttribute(temp,chatget);
%>
<%--保存用户聊天内容发送者 id 在application对象中--%>
<%
temp = chatroom + "chatgive" + chatpoint;
application.setAttribute(temp,chatgive);
%>
<%--设定用户聊天内容是否为私聊的标志,保存在application对象中--%>
<%
temp = chatroom + "chatprivate" + chatpoint;
application.setAttribute(temp,chatprivate);
%>
<%--保存用户聊天表情在application对象中--%>
<%
temp = chatroom + "chatface" + chatpoint;
application.setAttribute(temp,chatface);
%>
<%--保存用户设定的聊天内容刷新速度和在线用户列表刷新速度在session对象中--%>
<%
retime1 = request.getParameter("selre1");
retime2 = request.getParameter("selre2");
session.putValue("retime1",retime1);
session.putValue("retime2",retime2);
}
%><html>
<head>
<title>聊天室</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta http-equiv="Refresh" content="<%=retime1%>;url=chat.jsp?isret=yes">
</head><body bgcolor="#FFCCCC" leftmargin="20" topmargin="20">
<table width="550" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<%--显示保存过的所有聊天内容--%>
<%
if(chatpointn != 0){
%>
<%--
变量j标志着当前要显示的聊天信息的指针,首先从最新的信息开始显示,所以 j 等于chatpoint
--%>
<%
int j;
j = chatpointn;
//System.out.println(j);
//System.out.println("-----------------------------------");
for(int i=1;i<=30 && i<=j;i++){
%>
<%--得到以j为当前指针的聊天信息的各部分内容--%>
<%
String jtemp = new String();
jtemp = jtemp.valueOf(i);
temp = chatroom + "chatword" + jtemp;
chatword = (String)application.getAttribute(temp);
temp = chatroom + "chatcolor" + jtemp;
chatcolor = (String)application.getAttribute(temp);
temp = chatroom + "chatface" + jtemp;
chatface = (String)application.getAttribute(temp);
temp = chatroom + "chatprivate" + jtemp;
chatprivate = (String)application.getAttribute(temp);
temp = chatroom + "chatget" + jtemp;
chatget = (String)application.getAttribute(temp);
temp = chatroom + "chatgive" + jtemp;
chatgive = (String)application.getAttribute(temp);
%>
<%--
指针减 1 ,在下一次循环中将显示下一组聊天信息.当指针为 0 时,返回显示末尾记录
--%>
<%
//j--;
//System.out.println(j);
//if(j==0){
// j=30;
//}
%>
<%--chatprivate=null表明当前指针位置还没有内容,这种情况只会出现在聊天室刚刚启动application对象的变量中还没保存过聊天内容的时候--%>
<%
if(!(chatprivate==null)){
%>
<%--下面的判断添加如果为真表明当前指针所指向的聊天信息是可以显示的,其中一种为共有信息,另一种为接受者和发送者为当前执行程序的用户的私聊信息--%>
<%
if(chatprivate.equals("no") ||
(chatprivate.equals("yes") &&
(chatgive.equals(chatid) || chatget.equals(chatid) ) ) ) {
%>
<%--设定显示的颜色和字体大小--%>
<font size="2" color="<%=chatcolor%>">
<%--判断是否为系统公告信息,如果是则根据颜色显示不同的公告信息,红色表示是用户进入时的系统公告信息,绿色表明是用户离开时的系统公告信息--%>
<%
System.out.println(chatget);
if(chatprivate.equals("no") && chatget==null){
if(chatcolor.equals("red")){
%>
(系统公告)<%=chatword%>进入聊天室.
<%
} else {
chatword = (String)session.getValue("chatid");
System.out.println("$$$$$________________***********");
System.out.println(chatword);
System.out.println("$$$$$________________***********");
%>
(系统公告)<%=chatword%>离开聊天室.
<%
}
} else {
%>
<%--如果是私聊信息要加上"私聊" 字样--%>
<%
if(chatprivate.equals("yes")){
%>
(私聊)
<%
}
%>
<%--下面分别显示聊天的发送者,接受者,表情和聊天的内容--%>
<%
out.println(chatgive);
%>
对
<%
if(chatget.equals("all")){
%>
大家
<%
} else {
out.println(chatget);
}
%>
<%
int nn;
nn = Integer.parseInt(chatface);
switch(nn){
case 1:
%>
笑嘻嘻的
<%
break;
case 2:
%>
微笑着
<%
break;
case 3:
%>
充满拎爱的
<%
break;
case 4:
%>
含情脉脉的
<%
break;
case 5:
%>
做了个鬼脸
<%
break;
case 6:
%>
怒气冲冲的
<%
break;
case 7:
%>
有些生气的
<%
break;
case 8:
%>
冷笑着
<%
break;
case 9:
%>
嗔怪的
<%
break;
case 10:
%>
撒娇的
<%
}
%>
说:
<%
out.println(chatword);
}
%>
</font>
<br><br>
<%
}
}
}
}
%>
</td>
</tr>
</table>
</html>
<%@page contentType="text/html;charset=gbk"%><%
String chatid = new String();
chatid = (String)session.getValue("chatid");
//System.out.println("--------------------");
//System.out.println(chatid);
//System.out.println("--------------------");String chatroom = new String();
chatroom = (String)session.getValue("chatroom");
if(!(chatroom==null)){
%>
<%--用于保存用户所在聊天室总人数的 application 对象变量的数值减 1 --%>
<%
int num;
String numtemp = new String();
String temp = new String();
temp = chatroom + "usernum";
numtemp = (String)application.getAttribute(temp);
num = Integer.parseInt(numtemp);
num = num - 1;
numtemp = numtemp.valueOf(num);
application.setAttribute(temp,numtemp);
%>
<%--保存用户离开的系统公告信息--%>
<%
temp = chatroom + "chatpoint";
String chatpoint = new String();
chatpoint = (String)application.getAttribute(temp);
int chatpointn ;
chatpointn = Integer.parseInt(chatpoint);
chatpointn = chatpointn + 1;
if(chatpointn == 31){
chatpointn = 1;
}
chatpoint = chatpoint.valueOf(chatpointn);
temp = chatroom + "chatpoint";
application.setAttribute(temp,chatpoint);
temp = chatroom + "charword" + chatpoint;
application.setAttribute(temp,chatid);
temp = chatroom + "chatcolor" + chatpoint;
application.setAttribute(temp,"blue");
temp = chatroom + "chatprivate" + chatpoint;
application.setAttribute(temp,"no");
session.invalidate();
%><html>
<head>
<title>聊天室</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head><body bgcolor="#9999ff">
<div align="center">
<p> </p>
<p> </p>
<p><b>您已经成功退出聊天室</b></p>
<p><b>欢迎您常来</b></p>
<p> </p>
<p><a href="login.htm">重新登陆</a></p>
</div>
</body>
</html>
<%
} else {
%>
您还没有登陆
<%
}
%>
我需要的是即时消息的,web形式的,要求性能强的,可以承担上万人同时在线的聊天室,可以对聊天内容记录。
代码要是mvc的,最好是比软成熟的开源产品。因为要集成到我们的系统中使用。看open-open中的产品
http://www.open-open.com/52.htm
哪个用得更广?
如没清,那服务器不重启,那聊数据量太大了。