`
yacole
  • 浏览: 241213 次
  • 性别: Icon_minigender_1
  • 来自: 浙江科技学院
社区版块
存档分类
最新评论

JSP+AJAX 聊天室代码

阅读更多
tw-sack.js
js 代码
  1. /* Simple AJAX Code-Kit (SACK) */  
  2. /* 2005 Gregory Wild-Smith */  
  3. /* [url]www.twilightuniverse.com[/url] */  
  4. /* Software licenced under a modified X11 licence, see documentation or authors website for more details */  
  5.   
  6. function sack(file){   
  7. this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";   
  8. this.requestFile = file; // 提交的页面   
  9. this.method = "POST";   
  10. this.URLString = "";   
  11. this.encodeURIString = true;   
  12. this.execute = false;   
  13.   
  14. this.onLoading = function() { };//读取中   
  15. this.onLoaded = function() { };//已经读取   
  16. this.onInteractive = function() { };//交互中   
  17. this.onCompletion = function() { }; // 信息返回之后执行的方法   
  18. this.complete = function(){};//处理完毕   
  19. this.createAJAX = function() {   
  20. try {   
  21. this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");   
  22. catch (e) {   
  23. try {   
  24. this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");   
  25. catch (err) {   
  26. this.xmlhttp = null;   
  27. }   
  28. }   
  29. if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")   
  30. this.xmlhttp = new XMLHttpRequest();   
  31. if (!this.xmlhttp){   
  32. this.failed = true;   
  33. }   
  34. };   
  35.   
  36. this.setVar = function(name, value){   
  37. if (this.URLString.length < 3){   
  38. this.URLString = name + "=" + value;   
  39. else {   
  40. this.URLString += "&" + name + "=" + value;   
  41. }   
  42. }   
  43.   
  44. this.encVar = function(name, value){   
  45. var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);   
  46. return varString;   
  47. }   
  48.   
  49. this.encodeURLString = function(string){   
  50. varArray = string.split('&');   
  51. for (i = 0; i < varArray.length; i++){   
  52. urlVars = varArray[i].split('=');   
  53. if (urlVars[0].indexOf('amp;') != -1){   
  54. urlVars[0] = urlVars[0].substring(4);   
  55. }   
  56. varArray[i] = this.encVar(urlVars[0],urlVars[1]);   
  57. }   
  58. return varArray.join('&');   
  59. }   
  60.   
  61. this.runResponse = function(){   
  62. eval(this.response);   
  63. }   
  64.   
  65. this.runAJAX = function(urlstring){   
  66. this.responseStatus = new Array(2);   
  67. if(this.failed && this.AjaxFailedAlert){   
  68. alert(this.AjaxFailedAlert);   
  69. else {   
  70. if (urlstring){   
  71. if (this.URLString.length){   
  72. this.URLString = this.URLString + "&" + urlstring;   
  73. else {   
  74. this.URLString = urlstring;   
  75. }   
  76. }   
  77. if (this.encodeURIString){   
  78. var timeval = new Date().getTime();   
  79. this.URLString = this.encodeURLString(this.URLString);   
  80. this.setVar("rndval", timeval);   
  81. }   
  82. if (this.element) { this.elementObj = document.getElementById(this.element); }   
  83. if (this.xmlhttp) {   
  84. var self = this;   
  85. if (this.method == "GET") {   
  86. var totalurlstring = this.requestFile + "?" + this.URLString;   
  87. this.xmlhttp.open(this.method, totalurlstring, true);   
  88. else {   
  89. this.xmlhttp.open(this.method, this.requestFile, true);   
  90. }   
  91. if (this.method == "POST"){   
  92. try {   
  93. this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8')   
  94. catch (e) {}   
  95. }   
  96.   
  97. this.xmlhttp.send(this.URLString);   
  98. this.xmlhttp.onreadystatechange = function() {   
  99. switch (self.xmlhttp.readyState){   
  100. case 1: //读取中   
  101. self.onLoading();   
  102. break;   
  103. case 2: //已经读取   
  104. self.onLoaded();   
  105. break;   
  106. case 3: //交互中   
  107. self.onInteractive();   
  108. break;   
  109. case 4: //处理完毕   
  110. self.response = self.xmlhttp.responseText;   
  111. self.responseXML = self.xmlhttp.responseXML;   
  112. self.responseStatus[0] = self.xmlhttp.status;   
  113. self.responseStatus[1] = self.xmlhttp.statusText;   
  114. self.onCompletion();   
  115. if(self.execute){ self.runResponse(); }   
  116. if (self.elementObj) {   
  117. var elemNodeName = self.elementObj.nodeName;   
  118. elemNodeName.toLowerCase();   
  119. if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){   
  120. self.elementObj.value = self.response;   
  121. else {   
  122. self.elementObj.innerHTML = self.response;   
  123. }   
  124. }   
  125. self.URLString = "";   
  126. self.complete();   
  127. break;   
  128. }   
  129. };   
  130. }   
  131. }   
  132. };   
  133. this.createAJAX();   
  134. }   

display.js
js 代码
  1. function overInput(a){   
  2. getId("btn").style.border = "1px solid #54ce43"  
  3. getId("content").style.border = "1px solid #54ce43"  
  4. focs()   
  5. }   
  6. function outInput(a){   
  7. getId("btn").style.border = "1px solid #AAA"  
  8. getId("content").style.border = "1px solid #AAA"  
  9. focs()   
  10. }   
  11. function overBtn(a){   
  12. a.src = "images/hover.gif"  
  13. }   
  14. function outBtn(a){   
  15. a.src = "images/rest.gif"  
  16. }   
  17. function lrover(a){   
  18. a.style.backgroundColor = "#EEE"  
  19. }   
  20. function lrout(a){   
  21. a.style.backgroundColor = "#FFF"  
  22. }   
  23. function focs(){   
  24. getName("content").focus();   
  25. }   
  26. function clean(){   
  27. getName("content").value = ""  
  28. }   
  29. var chats = new Array()   
  30. var chatStart   
  31. function addChat(strChat){   
  32. if(chats.length > 199){   
  33. chats.shift()   
  34. }   
  35. chats.push(strChat)   
  36. chatStart = chats.length   
  37. }   
  38. function preChat(){   
  39. if(chatStart && chatStart >= 1){   
  40. if(chatStart == 1){   
  41. getName("content").value = chats[0]   
  42. chatStart = 0.5   
  43. }else{   
  44. chatStart -= 1   
  45. getName("content").value = chats[chatStart]   
  46. }   
  47. }   
  48. getId("loadifo").innerHTML = chatStart+","+chats.length   
  49. }   
  50. function nextChat(){   
  51. if(chatStart && chatStart < chats.length && chats.length > 1){   
  52. if(chatStart == 0.5){   
  53. chatStart = 1   
  54. }else if(chatStart == chats.length - 1){   
  55. chatStart = chats.length - 1   
  56. }else{   
  57. chatStart += 1   
  58. }   
  59. getName("content").value = chats[chatStart]   
  60. }   
  61. getId("loadifo").innerHTML = chatStart+","+chats.length   
  62. }   
  63. window.onload = function(){   
  64. getId("outs").onmousedown = function(){   
  65. overs = 1   
  66. }   
  67. getId("outs").onmouseout = function(){   
  68. overs = 0   
  69. focs()   
  70. }   
  71. getName("content").onkeydown = function(e){   
  72. if(document.all){   
  73. var Keys = event.keyCode;   
  74. }else{   
  75. var Keys = e.which;   
  76. }   
  77. //alert(Keys)   
  78. if(Keys == "38"){   
  79. preChat()   
  80. }else if(Keys == "40"){   
  81. nextChat()   
  82. }else if(event.ctrlKey && Keys == "13"){   
  83. doUsingPost()   
  84. }else if(event.ctrlKey && Keys == "46"){   
  85. clean()   
  86. }   
  87. }   
  88.   
  89. }   
  90. function getId(objId){   
  91. return document.getElementById(objId)   
  92. }   
  93. function getName(objName){   
  94. return document.getElementsByName(objName)[0]   
  95. }   

chat.js
js 代码
  1. var overs;   
  2. var clien = 0;   
  3. function doUsingGet(){   
  4. var ajax=new sack("chat.jsp");   
  5. ajax.setVar("clien",clien);   
  6. ajax.setVar("timeStamp",new Date().getTime());   
  7. ajax.method='GET';   
  8. ajax.onLoading=function(){   
  9. document.getElementById("zt").innerHTML="读取中......";   
  10. }   
  11. ajax.onCompletion=function(){// 信息返回之后执行的方法   
  12. CheckState(ajax.responseXML.documentElement);   
  13. }   
  14. ajax.onLoaded=function(){   
  15. document.getElementById("zt").innerHTML="已经读取......";   
  16. }   
  17. ajax.onInteractive=function(){   
  18. document.getElementById("zt").innerHTML="交互中......";   
  19. }   
  20. ajax.complete = function(){   
  21. document.getElementById("zt").innerHTML="处理完毕......";   
  22. }   
  23. ajax.runAJAX();   
  24. }   
  25. function doUsingPost(){   
  26. if(getName("content").value!=""){   
  27. var named = getName("named").value;   
  28. var content = getName("content").value;   
  29. var ajax=new sack("chat.jsp");   
  30. ajax.setVar("clien",clien);   
  31. ajax.setVar("content",content);   
  32. ajax.setVar("named",named);   
  33. ajax.setVar("timeStamp",new Date().getTime());   
  34. ajax.method='POST';   
  35. ajax.onLoading=function(){   
  36. document.getElementById("zt").innerHTML="读取中......";   
  37. }   
  38. ajax.onCompletion=function(){// 信息返回之后执行的方法   
  39. CheckState(ajax.responseXML.documentElement);   
  40. }   
  41. ajax.onLoaded=function(){   
  42. document.getElementById("zt").innerHTML="已经读取......";   
  43. }   
  44. ajax.onInteractive=function(){   
  45. document.getElementById("zt").innerHTML="交互中......";   
  46. }   
  47. ajax.complete = function(){   
  48. document.getElementById("zt").innerHTML="处理完毕......";   
  49. }   
  50. ajax.runAJAX();   
  51. focs();   
  52. clean();   
  53. }else{   
  54. alert("请输入对话内容!")   
  55. focs()   
  56. }   
  57. }   
  58.   
  59.   
  60. function CheckState(res){   
  61. var resLen = res.getElementsByTagName("items").length   
  62. if(getTag(res,0,"num") != clien){   
  63. clien = getTag(res,0,"num")   
  64. for(var i=0; i<resLen; i++){   
  65. var useName = getTag(res,i,"name")   
  66. var useMag = getTag(res,i,"conts")   
  67. var useIp = getTag(res,i,"ip")   
  68. if(clien != "0" && useMag != ""){   
  69. if(useName != ""){   
  70. var lis = "用户"+ useName + "说:" + useMag //+ " ["+ useIp + "]"   
  71. }else{   
  72. var lis = "用户 ["+ useIp + "] 说:" + useMag   
  73. }   
  74. }else{   
  75. var lis = ""  
  76. }   
  77. getId("chatmain").innerHTML += lis + "<br />"  
  78. }   
  79. innerSize()   
  80. }   
  81. }   
  82.   
  83. function innerSize(){   
  84. if(overs != 1){   
  85. if(getId("chatmain").offsetHeight < getId("outmain").offsetHeight){   
  86. getId("chatmain").style.marginTop = getId("outmain").offsetHeight - getId("chatmain").offsetHeight +"px";   
  87. }else{   
  88. getId("chatmain").scrollIntoView(false)   
  89. }   
  90. }   
  91. }   
  92. function getTag(response,i,objTagName){   
  93. try{   
  94. var nodeV = response.getElementsByTagName(objTagName)[i].firstChild.nodeValue;   
  95. }catch(e){   
  96. var nodeV = ""  
  97. }   
  98. return nodeV;   
  99. }   
  100. setInterval("doUsingGet()",1000)  


chat.jsp
jsp代码
  1. <%@ page contentType="text/xml; charset=gb2312" %>  
  2. <%!   
  3. String func(String content){   
  4. return content.replaceAll("<","<").replaceAll(">",">");   
  5. }   
  6. %>  
  7. <%   
  8. String ip=request.getRemoteAddr(); //客户端IP   
  9. int clien = new Integer(request.getParameter("clien")).intValue(); //当前是第几个用户 如果为0就是新来的用户   
  10. if(application.getAttribute("counts")==null){   
  11. application.setAttribute("counts",new Integer(0));   
  12. }   
  13. int counts = new Integer(application.getAttribute("counts").toString()).intValue(); //当前用户的ID   
  14. if(request.getParameter("content")!=null){   
  15. synchronized(this){   
  16. if(counts < 21){   
  17. int i = counts + 1;   
  18. application.setAttribute("counts",new Integer(i));   
  19. }else if(counts >= 21){   
  20. application.setAttribute("counts","1");   
  21. }   
  22. counts = new Integer(application.getAttribute("counts").toString()).intValue(); //当前用户的ID   
  23. int Cnum = counts;   
  24. String names;   
  25. String Msgs = request.getParameter("content");   
  26. // Msgs=new String(Msgs.getBytes("iso8859-1"),"gb2312");   
  27. application.setAttribute("ips" + Cnum,ip) ;   
  28. application.setAttribute("msgs" + Cnum,func(Msgs)) ;   
  29. if(request.getParameterValues("content") != null){   
  30. names = request.getParameter("named");   
  31. }else{   
  32. names = "";   
  33. }   
  34. application.setAttribute("names" + Cnum,names +"") ;   
  35. }   
  36. }   
  37. %><?xml version="1.0" encoding="gb2312" ?>  
  38. <ppl>  
  39. <num><%=application.getAttribute("counts")%></num>  
  40. <%   
  41. if(clien == 0){   
  42. %>  
  43. <items>  
  44. <ip><%=ip%></ip>  
  45. </items>  
  46. <%   
  47. }else if(clien < counts){   
  48. for(int i=clien; i<counts; i++){   
  49. int s = i+1;   
  50. String useName = (String)application.getAttribute("names" + s);   
  51. String useMsg = (String)application.getAttribute("msgs" + s);   
  52. String useIp = (String)application.getAttribute("ips" + s);   
  53. %>  
  54. <items>  
  55. <aaa><%=clien%> <%=s%></aaa>  
  56. <bbb><%=counts%></bbb>  
  57. <name><%=useName%></name>  
  58. <conts><%=useMsg%></conts>  
  59. <ip><%=useIp%></ip>  
  60. </items>  
  61. <%   
  62. }   
  63. }else if(clien > counts){   
  64. for(int i=clien; i<21; i++){   
  65. String useName = (String)application.getAttribute("names" + i);   
  66. String useMsg = (String)application.getAttribute("msgs" + i);   
  67. String useIp = (String)application.getAttribute("ips" + i);   
  68. %>  
  69. <items>  
  70. <name><%=useName%></name>  
  71. <conts><%=useMsg%></conts>  
  72. <ip><%=useIp%></ip>  
  73. </items>  
  74. <%   
  75. }   
  76. for(int m=1; m<=counts; m++){   
  77. String useNameM = (String)application.getAttribute("names" + m);   
  78. String useMsgM = (String)application.getAttribute("msgs" + m);   
  79. String useIpM = (String)application.getAttribute("ips" + m);   
  80. %>  
  81. <items>  
  82. <name><%=useNameM%></name>  
  83. <conts><%=useMsgM%></conts>  
  84. <ip><%=useIpM%></ip>  
  85. </items>  
  86. <%   
  87. }   
  88. }else if(clien == counts){   
  89.   
  90. }   
  91. %>  
  92. </ppl>  

index.html
html 代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title></title>  
  6. <link href="images/chatstyle.css" rel="stylesheet" type="text/css" />  
  7.   
  8. <script type="text/javascript" src="js/display.js"></script>  
  9. <script type="text/javascript" src="js/chat.js"></script>  
  10. <script type="text/javascript" src="js/tw-sack.js"></script>  
  11.   
  12. </head>  
  13. <body>  
  14. <div id="zt"></div>  
  15. <div id="loadifo"></div>  
  16. <div id="outs"><div id="outmain"><div id="chatmain"></div></div></div>  
  17. <div class="in">昵称:   
分享到:
评论
2 楼 浅浅陌上桑 2016-04-14  
为什么最后一个是不完整的
1 楼 lijianbin 2007-07-16  
<strong><span style="COLOR: #ff0000">tw-sack.js</span></strong><br />
<div class="code_title">js 代码</div>
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-c">
    <li class="alt"><span><span class="comment">/*&nbsp;Simple&nbsp;AJAX&nbsp;Code-Kit&nbsp;(SACK)&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span></span><span class="comment">/*&nbsp;2005&nbsp;Gregory&nbsp;Wild-Smith&nbsp;*/</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="comment">/*&nbsp;www.twilightuniverse.com&nbsp;*/</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="comment">/*&nbsp;Software&nbsp;licenced&nbsp;under&nbsp;a&nbsp;modified&nbsp;X11&nbsp;licence,&nbsp;see&nbsp;documentation&nbsp;or&nbsp;authors&nbsp;website&nbsp;for&nbsp;more&nbsp;details&nbsp;*/</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;sack(file){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.AjaxFailedAlert&nbsp;=&nbsp;</span><span class="string">&quot;Your&nbsp;browser&nbsp;does&nbsp;not&nbsp;support&nbsp;the&nbsp;enhanced&nbsp;functionality&nbsp;of&nbsp;this&nbsp;website,&nbsp;and&nbsp;therefore&nbsp;you&nbsp;will&nbsp;have&nbsp;an&nbsp;experience&nbsp;that&nbsp;differs&nbsp;from&nbsp;the&nbsp;intended&nbsp;one.\n&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.requestFile&nbsp;=&nbsp;file;&nbsp;</span><span class="comment">//&nbsp;提交的页面 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.method&nbsp;=&nbsp;</span><span class="string">&quot;POST&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.URLString&nbsp;=&nbsp;</span><span class="string">&quot;&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.encodeURIString&nbsp;=&nbsp;</span><span class="keyword">true</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.execute&nbsp;=&nbsp;</span><span class="keyword">false</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.onLoading&nbsp;=&nbsp;</span><span class="keyword">function</span><span>()&nbsp;{&nbsp;};</span><span class="comment">//读取中 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.onLoaded&nbsp;=&nbsp;</span><span class="keyword">function</span><span>()&nbsp;{&nbsp;};</span><span class="comment">//已经读取 </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.onInteractive&nbsp;=&nbsp;</span><span class="keyword">function</span><span>()&nbsp;{&nbsp;};</span><span class="comment">//交互中 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.onCompletion&nbsp;=&nbsp;</span><span class="keyword">function</span><span>()&nbsp;{&nbsp;};&nbsp;</span><span class="comment">//&nbsp;信息返回之后执行的方法 </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.complete&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){};</span><span class="comment">//处理完毕 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.createAJAX&nbsp;=&nbsp;</span><span class="keyword">function</span><span>()&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">try</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.xmlhttp&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;ActiveXObject(</span><span class="string">&quot;Microsoft.XMLHTTP&quot;</span><span>); &nbsp;&nbsp;</span></li>
    <li class=""><span>}&nbsp;</span><span class="keyword">catch</span><span>&nbsp;(e)&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">try</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.xmlhttp&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;ActiveXObject(</span><span class="string">&quot;Msxml2.XMLHTTP&quot;</span><span>); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}&nbsp;</span><span class="keyword">catch</span><span>&nbsp;(err)&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.xmlhttp&nbsp;=&nbsp;</span><span class="keyword">null</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(!</span><span class="keyword">this</span><span>.xmlhttp&nbsp;&amp;&amp;&nbsp;</span><span class="keyword">typeof</span><span>&nbsp;XMLHttpRequest&nbsp;!=&nbsp;</span><span class="string">&quot;undefined&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.xmlhttp&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;XMLHttpRequest(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(!</span><span class="keyword">this</span><span>.xmlhttp){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.failed&nbsp;=&nbsp;</span><span class="keyword">true</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>}; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.setVar&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(name,&nbsp;value){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.URLString.length&nbsp;&lt;&nbsp;3){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.URLString&nbsp;=&nbsp;name&nbsp;+&nbsp;</span><span class="string">&quot;=&quot;</span><span>&nbsp;+&nbsp;value; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}&nbsp;</span><span class="keyword">else</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.URLString&nbsp;+=&nbsp;</span><span class="string">&quot;&amp;&quot;</span><span>&nbsp;+&nbsp;name&nbsp;+&nbsp;</span><span class="string">&quot;=&quot;</span><span>&nbsp;+&nbsp;value; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.encVar&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(name,&nbsp;value){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;varString&nbsp;=&nbsp;encodeURIComponent(name)&nbsp;+&nbsp;</span><span class="string">&quot;=&quot;</span><span>&nbsp;+&nbsp;encodeURIComponent(value); &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">return</span><span>&nbsp;varString; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.encodeURLString&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(string){ &nbsp;&nbsp;</span></li>
    <li class=""><span>varArray&nbsp;=&nbsp;string.split('&amp;'); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">for</span><span>&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;varArray.length;&nbsp;i++){ &nbsp;&nbsp;</span></li>
    <li class=""><span>urlVars&nbsp;=&nbsp;varArray[i].split('='); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(urlVars[0].indexOf('amp;')&nbsp;!=&nbsp;-1){ &nbsp;&nbsp;</span></li>
    <li class=""><span>urlVars[0]&nbsp;=&nbsp;urlVars[0].substring(4); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>varArray[i]&nbsp;=&nbsp;</span><span class="keyword">this</span><span>.encVar(urlVars[0],urlVars[1]); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">return</span><span>&nbsp;varArray.join('&amp;'); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.runResponse&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>eval(</span><span class="keyword">this</span><span>.response); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.runAJAX&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(urlstring){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.responseStatus&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;Array(2); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(</span><span class="keyword">this</span><span>.failed&nbsp;&amp;&amp;&nbsp;</span><span class="keyword">this</span><span>.AjaxFailedAlert){ &nbsp;&nbsp;</span></li>
    <li class=""><span>alert(</span><span class="keyword">this</span><span>.AjaxFailedAlert); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}&nbsp;</span><span class="keyword">else</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>&nbsp;(urlstring){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.URLString.length){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.URLString&nbsp;=&nbsp;</span><span class="keyword">this</span><span>.URLString&nbsp;+&nbsp;</span><span class="string">&quot;&amp;&quot;</span><span>&nbsp;+&nbsp;urlstring; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}&nbsp;</span><span class="keyword">else</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.URLString&nbsp;=&nbsp;urlstring; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.encodeURIString){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;timeval&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;Date().getTime(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.URLString&nbsp;=&nbsp;</span><span class="keyword">this</span><span>.encodeURLString(</span><span class="keyword">this</span><span>.URLString); &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.setVar(</span><span class="string">&quot;rndval&quot;</span><span>,&nbsp;timeval); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.element)&nbsp;{&nbsp;</span><span class="keyword">this</span><span>.elementObj&nbsp;=&nbsp;document.getElementById(</span><span class="keyword">this</span><span>.element);&nbsp;} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.xmlhttp)&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;self&nbsp;=&nbsp;</span><span class="keyword">this</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.method&nbsp;==&nbsp;</span><span class="string">&quot;GET&quot;</span><span>)&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;totalurlstring&nbsp;=&nbsp;</span><span class="keyword">this</span><span>.requestFile&nbsp;+&nbsp;</span><span class="string">&quot;?&quot;</span><span>&nbsp;+&nbsp;</span><span class="keyword">this</span><span>.URLString; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.xmlhttp.open(</span><span class="keyword">this</span><span>.method,&nbsp;totalurlstring,&nbsp;</span><span class="keyword">true</span><span>); &nbsp;&nbsp;</span></li>
    <li class=""><span>}&nbsp;</span><span class="keyword">else</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.xmlhttp.open(</span><span class="keyword">this</span><span>.method,&nbsp;</span><span class="keyword">this</span><span>.requestFile,&nbsp;</span><span class="keyword">true</span><span>); &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(</span><span class="keyword">this</span><span>.method&nbsp;==&nbsp;</span><span class="string">&quot;POST&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">try</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8') &nbsp;&nbsp;</span></li>
    <li class=""><span>}&nbsp;</span><span class="keyword">catch</span><span>&nbsp;(e)&nbsp;{} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.xmlhttp.send(</span><span class="keyword">this</span><span>.URLString); &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">this</span><span>.xmlhttp.onreadystatechange&nbsp;=&nbsp;</span><span class="keyword">function</span><span>()&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">switch</span><span>&nbsp;(self.xmlhttp.readyState){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">case</span><span>&nbsp;1:&nbsp;</span><span class="comment">//读取中 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>self.onLoading(); &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">break</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">case</span><span>&nbsp;2:&nbsp;</span><span class="comment">//已经读取 </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>self.onLoaded(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">break</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">case</span><span>&nbsp;3:&nbsp;</span><span class="comment">//交互中 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>self.onInteractive(); &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">break</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">case</span><span>&nbsp;4:&nbsp;</span><span class="comment">//处理完毕 </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>self.response&nbsp;=&nbsp;self.xmlhttp.responseText; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>self.responseXML&nbsp;=&nbsp;self.xmlhttp.responseXML; &nbsp;&nbsp;</span></li>
    <li class=""><span>self.responseStatus[0]&nbsp;=&nbsp;self.xmlhttp.status; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>self.responseStatus[1]&nbsp;=&nbsp;self.xmlhttp.statusText; &nbsp;&nbsp;</span></li>
    <li class=""><span>self.onCompletion(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(self.execute){&nbsp;self.runResponse();&nbsp;} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>&nbsp;(self.elementObj)&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;elemNodeName&nbsp;=&nbsp;self.elementObj.nodeName; &nbsp;&nbsp;</span></li>
    <li class=""><span>elemNodeName.toLowerCase(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>&nbsp;(elemNodeName&nbsp;==&nbsp;</span><span class="string">&quot;input&quot;</span><span>&nbsp;||&nbsp;elemNodeName&nbsp;==&nbsp;</span><span class="string">&quot;select&quot;</span><span>&nbsp;||&nbsp;elemNodeName&nbsp;==&nbsp;</span><span class="string">&quot;option&quot;</span><span>&nbsp;||&nbsp;elemNodeName&nbsp;==&nbsp;</span><span class="string">&quot;textarea&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class=""><span>self.elementObj.value&nbsp;=&nbsp;self.response; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}&nbsp;</span><span class="keyword">else</span><span>&nbsp;{ &nbsp;&nbsp;</span></li>
    <li class=""><span>self.elementObj.innerHTML&nbsp;=&nbsp;self.response; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>self.URLString&nbsp;=&nbsp;</span><span class="string">&quot;&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>self.complete(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">break</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>}; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">this</span><span>.createAJAX(); &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
</ol>
</div>
<br />
<strong><span style="COLOR: #ff0000">display.js</span></strong><br />
<div class="code_title">js 代码</div>
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-c">
    <li class="alt"><span><span class="keyword">function</span><span>&nbsp;overInput(a){ &nbsp;&nbsp;</span></span></li>
    <li class=""><span>getId(</span><span class="string">&quot;btn&quot;</span><span>).style.border&nbsp;=&nbsp;</span><span class="string">&quot;1px&nbsp;solid&nbsp;#54ce43&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>getId(</span><span class="string">&quot;content&quot;</span><span>).style.border&nbsp;=&nbsp;</span><span class="string">&quot;1px&nbsp;solid&nbsp;#54ce43&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>focs() &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;outInput(a){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getId(</span><span class="string">&quot;btn&quot;</span><span>).style.border&nbsp;=&nbsp;</span><span class="string">&quot;1px&nbsp;solid&nbsp;#AAA&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>getId(</span><span class="string">&quot;content&quot;</span><span>).style.border&nbsp;=&nbsp;</span><span class="string">&quot;1px&nbsp;solid&nbsp;#AAA&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>focs() &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;overBtn(a){ &nbsp;&nbsp;</span></li>
    <li class=""><span>a.src&nbsp;=&nbsp;</span><span class="string">&quot;images/hover.gif&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;outBtn(a){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>a.src&nbsp;=&nbsp;</span><span class="string">&quot;images/rest.gif&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;lrover(a){ &nbsp;&nbsp;</span></li>
    <li class=""><span>a.style.backgroundColor&nbsp;=&nbsp;</span><span class="string">&quot;#EEE&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;lrout(a){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>a.style.backgroundColor&nbsp;=&nbsp;</span><span class="string">&quot;#FFF&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;focs(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>getName(</span><span class="string">&quot;content&quot;</span><span>).focus(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;clean(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getName(</span><span class="string">&quot;content&quot;</span><span>).value&nbsp;=&nbsp;</span><span class="string">&quot;&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;chats&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;Array() &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;chatStart &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;addChat(strChat){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(chats.length&nbsp;&gt;&nbsp;199){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>chats.shift() &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>chats.push(strChat) &nbsp;&nbsp;</span></li>
    <li class=""><span>chatStart&nbsp;=&nbsp;chats.length &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;preChat(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(chatStart&nbsp;&amp;&amp;&nbsp;chatStart&nbsp;&gt;=&nbsp;1){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(chatStart&nbsp;==&nbsp;1){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getName(</span><span class="string">&quot;content&quot;</span><span>).value&nbsp;=&nbsp;chats[0] &nbsp;&nbsp;</span></li>
    <li class=""><span>chatStart&nbsp;=&nbsp;0.5 &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class=""><span>chatStart&nbsp;-=&nbsp;1 &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getName(</span><span class="string">&quot;content&quot;</span><span>).value&nbsp;=&nbsp;chats[chatStart] &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>getId(</span><span class="string">&quot;loadifo&quot;</span><span>).innerHTML&nbsp;=&nbsp;chatStart+</span><span class="string">&quot;,&quot;</span><span>+chats.length &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;nextChat(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(chatStart&nbsp;&amp;&amp;&nbsp;chatStart&nbsp;&lt;&nbsp;chats.length&nbsp;&amp;&amp;&nbsp;chats.length&nbsp;&gt;&nbsp;1){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(chatStart&nbsp;==&nbsp;0.5){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>chatStart&nbsp;=&nbsp;1 &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>&nbsp;</span><span class="keyword">if</span><span>(chatStart&nbsp;==&nbsp;chats.length&nbsp;-&nbsp;1){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>chatStart&nbsp;=&nbsp;chats.length&nbsp;-&nbsp;1 &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>chatStart&nbsp;+=&nbsp;1 &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getName(</span><span class="string">&quot;content&quot;</span><span>).value&nbsp;=&nbsp;chats[chatStart] &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getId(</span><span class="string">&quot;loadifo&quot;</span><span>).innerHTML&nbsp;=&nbsp;chatStart+</span><span class="string">&quot;,&quot;</span><span>+chats.length &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>window.onload&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>getId(</span><span class="string">&quot;outs&quot;</span><span>).onmousedown&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>overs&nbsp;=&nbsp;1 &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getId(</span><span class="string">&quot;outs&quot;</span><span>).onmouseout&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>overs&nbsp;=&nbsp;0 &nbsp;&nbsp;</span></li>
    <li class="alt"><span>focs() &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getName(</span><span class="string">&quot;content&quot;</span><span>).onkeydown&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(e){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(document.all){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;Keys&nbsp;=&nbsp;event.keyCode; &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;Keys&nbsp;=&nbsp;e.which; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="comment">//alert(Keys) </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(Keys&nbsp;==&nbsp;</span><span class="string">&quot;38&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>preChat() &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>&nbsp;</span><span class="keyword">if</span><span>(Keys&nbsp;==&nbsp;</span><span class="string">&quot;40&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>nextChat() &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>&nbsp;</span><span class="keyword">if</span><span>(event.ctrlKey&nbsp;&amp;&amp;&nbsp;Keys&nbsp;==&nbsp;</span><span class="string">&quot;13&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>doUsingPost() &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>&nbsp;</span><span class="keyword">if</span><span>(event.ctrlKey&nbsp;&amp;&amp;&nbsp;Keys&nbsp;==&nbsp;</span><span class="string">&quot;46&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>clean() &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;getId(objId){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">return</span><span>&nbsp;document.getElementById(objId) &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;getName(objName){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">return</span><span>&nbsp;document.getElementsByName(objName)[0] &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
</ol>
</div>
<br />
<font color="#ff0000"><strong>chat.js</strong></font><br />
<div class="code_title">js 代码</div>
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-c">
    <li class="alt"><span><span class="keyword">var</span><span>&nbsp;overs; &nbsp;&nbsp;</span></span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;clien&nbsp;=&nbsp;0; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;doUsingGet(){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;ajax=</span><span class="keyword">new</span><span>&nbsp;sack(</span><span class="string">&quot;chat.jsp&quot;</span><span>); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.setVar(</span><span class="string">&quot;clien&quot;</span><span>,clien); &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.setVar(</span><span class="string">&quot;timeStamp&quot;</span><span>,</span><span class="keyword">new</span><span>&nbsp;Date().getTime()); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.method='GET'; &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.onLoading=</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;读取中......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.onCompletion=</span><span class="keyword">function</span><span>(){</span><span class="comment">//&nbsp;信息返回之后执行的方法 </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>CheckState(ajax.responseXML.documentElement); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.onLoaded=</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;已经读取......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.onInteractive=</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;交互中......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.complete&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;处理完毕......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.runAJAX(); &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;doUsingPost(){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(getName(</span><span class="string">&quot;content&quot;</span><span>).value!=</span><span class="string">&quot;&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;named&nbsp;=&nbsp;getName(</span><span class="string">&quot;named&quot;</span><span>).value; &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;content&nbsp;=&nbsp;getName(</span><span class="string">&quot;content&quot;</span><span>).value; &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;ajax=</span><span class="keyword">new</span><span>&nbsp;sack(</span><span class="string">&quot;chat.jsp&quot;</span><span>); &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.setVar(</span><span class="string">&quot;clien&quot;</span><span>,clien); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.setVar(</span><span class="string">&quot;content&quot;</span><span>,content); &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.setVar(</span><span class="string">&quot;named&quot;</span><span>,named); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.setVar(</span><span class="string">&quot;timeStamp&quot;</span><span>,</span><span class="keyword">new</span><span>&nbsp;Date().getTime()); &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.method='POST'; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.onLoading=</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;读取中......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.onCompletion=</span><span class="keyword">function</span><span>(){</span><span class="comment">//&nbsp;信息返回之后执行的方法 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>CheckState(ajax.responseXML.documentElement); &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.onLoaded=</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;已经读取......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.onInteractive=</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;交互中......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>ajax.complete&nbsp;=&nbsp;</span><span class="keyword">function</span><span>(){ &nbsp;&nbsp;</span></li>
    <li class=""><span>document.getElementById(</span><span class="string">&quot;zt&quot;</span><span>).innerHTML=</span><span class="string">&quot;处理完毕......&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>ajax.runAJAX(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>focs(); &nbsp;&nbsp;</span></li>
    <li class=""><span>clean(); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class=""><span>alert(</span><span class="string">&quot;请输入对话内容!&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class="alt"><span>focs() &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;CheckState(res){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;resLen&nbsp;=&nbsp;res.getElementsByTagName(</span><span class="string">&quot;items&quot;</span><span>).length &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(getTag(res,0,</span><span class="string">&quot;num&quot;</span><span>)&nbsp;!=&nbsp;clien){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>clien&nbsp;=&nbsp;getTag(res,0,</span><span class="string">&quot;num&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">for</span><span>(</span><span class="keyword">var</span><span>&nbsp;i=0;&nbsp;i&lt;resLen;&nbsp;i++){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;useName&nbsp;=&nbsp;getTag(res,i,</span><span class="string">&quot;name&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;useMag&nbsp;=&nbsp;getTag(res,i,</span><span class="string">&quot;conts&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;useIp&nbsp;=&nbsp;getTag(res,i,</span><span class="string">&quot;ip&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(clien&nbsp;!=&nbsp;</span><span class="string">&quot;0&quot;</span><span>&nbsp;&amp;&amp;&nbsp;useMag&nbsp;!=&nbsp;</span><span class="string">&quot;&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(useName&nbsp;!=&nbsp;</span><span class="string">&quot;&quot;</span><span>){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;lis&nbsp;=&nbsp;</span><span class="string">&quot;用户&quot;</span><span>+&nbsp;useName&nbsp;+&nbsp;</span><span class="string">&quot;说:&quot;</span><span>&nbsp;+&nbsp;useMag&nbsp;</span><span class="comment">//+&nbsp;&quot;&nbsp;[&quot;+&nbsp;useIp&nbsp;+&nbsp;&quot;]&quot; </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;lis&nbsp;=&nbsp;</span><span class="string">&quot;用户&nbsp;[&quot;</span><span>+&nbsp;useIp&nbsp;+&nbsp;</span><span class="string">&quot;]&nbsp;说:&quot;</span><span>&nbsp;+&nbsp;useMag &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">var</span><span>&nbsp;lis&nbsp;=&nbsp;</span><span class="string">&quot;&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>getId(</span><span class="string">&quot;chatmain&quot;</span><span>).innerHTML&nbsp;+=&nbsp;lis&nbsp;+&nbsp;</span><span class="string">&quot;&lt;br&nbsp;/&gt;&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>innerSize() &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">function</span><span>&nbsp;innerSize(){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">if</span><span>(overs&nbsp;!=&nbsp;1){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">if</span><span>(getId(</span><span class="string">&quot;chatmain&quot;</span><span>).offsetHeight&nbsp;&lt;&nbsp;getId(</span><span class="string">&quot;outmain&quot;</span><span>).offsetHeight){ &nbsp;&nbsp;</span></li>
    <li class=""><span>getId(</span><span class="string">&quot;chatmain&quot;</span><span>).style.marginTop&nbsp;=&nbsp;getId(</span><span class="string">&quot;outmain&quot;</span><span>).offsetHeight&nbsp;-&nbsp;getId(</span><span class="string">&quot;chatmain&quot;</span><span>).offsetHeight&nbsp;+</span><span class="string">&quot;px&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}</span><span class="keyword">else</span><span>{ &nbsp;&nbsp;</span></li>
    <li class=""><span>getId(</span><span class="string">&quot;chatmain&quot;</span><span>).scrollIntoView(</span><span class="keyword">false</span><span>) &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">function</span><span>&nbsp;getTag(response,i,objTagName){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="keyword">try</span><span>{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;nodeV&nbsp;=&nbsp;response.getElementsByTagName(objTagName)[i].firstChild.nodeValue; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}</span><span class="keyword">catch</span><span>(e){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">var</span><span>&nbsp;nodeV&nbsp;=&nbsp;</span><span class="string">&quot;&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="keyword">return</span><span>&nbsp;nodeV; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>setInterval(</span><span class="string">&quot;doUsingGet()&quot;</span><span>,1000)&nbsp;&nbsp;</span></li>
</ol>
</div>
<br />
<br />
<strong><span style="COLOR: #ff0000">chat.jsp</span></strong><br />
<div class="code_title">jsp代码</div>
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-xml">
    <li class="alt"><span><span class="tag">&lt;</span><span>%@&nbsp;page&nbsp;</span><span class="attribute">contentType</span><span>=</span><span class="attribute-value">&quot;text/xml;&nbsp;charset=gb2312&quot;</span><span>&nbsp;%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span>%! &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;func(String&nbsp;content){ &nbsp;&nbsp;</span></li>
    <li class=""><span>return&nbsp;content.replaceAll(&quot;</span><span class="tag">&lt;</span><span>&quot;,&quot;<&quot;).replaceAll(&quot;</span><span class="tag">&gt;</span><span>&quot;,&quot;>&quot;); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span>% &nbsp;&nbsp;</span></li>
    <li class=""><span>String&nbsp;</span><span class="attribute">ip</span><span>=</span><span class="attribute-value">request</span><span>.getRemoteAddr();&nbsp;//客户端IP &nbsp;&nbsp;</span></li>
    <li class="alt"><span>int&nbsp;</span><span class="attribute">clien</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">new</span><span>&nbsp;Integer(request.getParameter(&quot;clien&quot;)).intValue();&nbsp;//当前是第几个用户&nbsp;如果为0就是新来的用户 &nbsp;&nbsp;</span></li>
    <li class=""><span>if(application.getAttribute(&quot;counts&quot;)==null){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>application.setAttribute(&quot;counts&quot;,new&nbsp;Integer(0)); &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>int&nbsp;</span><span class="attribute">counts</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">new</span><span>&nbsp;Integer(application.getAttribute(&quot;counts&quot;).toString()).intValue();&nbsp;//当前用户的ID &nbsp;&nbsp;</span></li>
    <li class=""><span>if(request.getParameter(&quot;content&quot;)!=null){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>synchronized(this){ &nbsp;&nbsp;</span></li>
    <li class=""><span>if(counts&nbsp;</span><span class="tag">&lt;</span><span>&nbsp;</span><span class="tag-name">21</span><span>){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>int&nbsp;</span><span class="attribute">i</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">counts</span><span>&nbsp;+&nbsp;1; &nbsp;&nbsp;</span></li>
    <li class=""><span>application.setAttribute(&quot;counts&quot;,new&nbsp;Integer(i)); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}else&nbsp;if(counts&nbsp;</span><span class="tag">&gt;</span><span>=&nbsp;21){ &nbsp;&nbsp;</span></li>
    <li class=""><span>application.setAttribute(&quot;counts&quot;,&quot;1&quot;); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="attribute">counts</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">new</span><span>&nbsp;Integer(application.getAttribute(&quot;counts&quot;).toString()).intValue();&nbsp;//当前用户的ID &nbsp;&nbsp;</span></li>
    <li class="alt"><span>int&nbsp;</span><span class="attribute">Cnum</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">counts</span><span>; &nbsp;&nbsp;</span></li>
    <li class=""><span>String&nbsp;names; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;</span><span class="attribute">Msgs</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">request</span><span>.getParameter(&quot;content&quot;); &nbsp;&nbsp;</span></li>
    <li class=""><span>//&nbsp;</span><span class="attribute">Msgs</span><span>=</span><span class="attribute-value">new</span><span>&nbsp;String(Msgs.getBytes(&quot;iso8859-1&quot;),&quot;gb2312&quot;); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>application.setAttribute(&quot;ips&quot;&nbsp;+&nbsp;Cnum,ip)&nbsp;; &nbsp;&nbsp;</span></li>
    <li class=""><span>application.setAttribute(&quot;msgs&quot;&nbsp;+&nbsp;Cnum,func(Msgs))&nbsp;; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>if(request.getParameterValues(&quot;content&quot;)&nbsp;!=&nbsp;null){ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="attribute">names</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">request</span><span>.getParameter(&quot;named&quot;); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}else{ &nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="attribute">names</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">&quot;&quot;</span><span>; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>application.setAttribute(&quot;names&quot;&nbsp;+&nbsp;Cnum,names&nbsp;+&quot;&quot;)&nbsp;; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>%</span><span class="tag">&gt;</span><span class="tag">&lt;?</span><span class="tag-name">xml</span><span>&nbsp;</span><span class="attribute">version</span><span>=</span><span class="attribute-value">&quot;1.0&quot;</span><span>&nbsp;</span><span class="attribute">encoding</span><span>=</span><span class="attribute-value">&quot;gb2312&quot;</span><span>&nbsp;</span><span class="tag">?&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">ppl</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">num</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=application.getAttribute(&quot;counts&quot;)%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">num</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span>% &nbsp;&nbsp;</span></li>
    <li class="alt"><span>if(</span><span class="attribute">clien</span><span>&nbsp;==&nbsp;0){ &nbsp;&nbsp;</span></li>
    <li class=""><span>%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=ip%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;/</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span>% &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}else&nbsp;if(clien&nbsp;</span><span class="tag">&lt;</span><span>&nbsp;</span><span class="tag-name">counts</span><span>){ &nbsp;&nbsp;</span></li>
    <li class=""><span>for(int&nbsp;</span><span class="attribute">i</span><span>=</span><span class="attribute-value">clien</span><span>;&nbsp;i</span><span class="tag">&lt;</span><span class="tag-name">counts</span><span>;&nbsp;i++){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>int&nbsp;</span><span class="attribute">s</span><span>&nbsp;=&nbsp;</span><span class="attribute-value">i</span><span>+1; &nbsp;&nbsp;</span></li>
    <li class=""><span>String&nbsp;</span><span class="attribute">useName</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;names&quot;&nbsp;+&nbsp;s); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;</span><span class="attribute">useMsg</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;msgs&quot;&nbsp;+&nbsp;s); &nbsp;&nbsp;</span></li>
    <li class=""><span>String&nbsp;</span><span class="attribute">useIp</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;ips&quot;&nbsp;+&nbsp;s); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">aaa</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=clien%</span><span class="tag">&gt;</span><span>&nbsp;</span><span class="tag">&lt;</span><span>%=s%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">aaa</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">bbb</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=counts%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">bbb</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">name</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useName%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">name</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">conts</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useMsg%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">conts</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useIp%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;/</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span>% &nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>}else&nbsp;if(clien&nbsp;</span><span class="tag">&gt;</span><span>&nbsp;counts){ &nbsp;&nbsp;</span></li>
    <li class=""><span>for(int&nbsp;</span><span class="attribute">i</span><span>=</span><span class="attribute-value">clien</span><span>;&nbsp;i</span><span class="tag">&lt;</span><span class="tag-name">21</span><span>;&nbsp;i++){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;</span><span class="attribute">useName</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;names&quot;&nbsp;+&nbsp;i); &nbsp;&nbsp;</span></li>
    <li class=""><span>String&nbsp;</span><span class="attribute">useMsg</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;msgs&quot;&nbsp;+&nbsp;i); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;</span><span class="attribute">useIp</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;ips&quot;&nbsp;+&nbsp;i); &nbsp;&nbsp;</span></li>
    <li class=""><span>%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">name</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useName%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">name</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">conts</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useMsg%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">conts</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useIp%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;/</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span>% &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>for(int&nbsp;</span><span class="attribute">m</span><span>=</span><span class="attribute-value">1</span><span>;&nbsp;m</span><span class="tag">&lt;</span><span>=counts;&nbsp;m++){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;</span><span class="attribute">useNameM</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;names&quot;&nbsp;+&nbsp;m); &nbsp;&nbsp;</span></li>
    <li class=""><span>String&nbsp;</span><span class="attribute">useMsgM</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;msgs&quot;&nbsp;+&nbsp;m); &nbsp;&nbsp;</span></li>
    <li class="alt"><span>String&nbsp;</span><span class="attribute">useIpM</span><span>&nbsp;=&nbsp;(String)application.getAttribute(&quot;ips&quot;&nbsp;+&nbsp;m); &nbsp;&nbsp;</span></li>
    <li class=""><span>%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">name</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useNameM%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">name</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">conts</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useMsgM%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">conts</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span>%=useIpM%</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">ip</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;/</span><span class="tag-name">items</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span>% &nbsp;&nbsp;</span></li>
    <li class="alt"><span>} &nbsp;&nbsp;</span></li>
    <li class=""><span>}else&nbsp;if(</span><span class="attribute">clien</span><span>&nbsp;==&nbsp;counts){ &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>} &nbsp;&nbsp;</span></li>
    <li class="alt"><span>%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;/</span><span class="tag-name">ppl</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
</ol>
</div>
<br />
<strong><span style="COLOR: #ff0000">index.html</span></strong><br />
<div class="code_title">html&nbsp;代码</div>
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-xml">
    <li class="alt"><span><span>&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;&quot;-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Transitional//EN&quot;&nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">html</span><span>&nbsp;</span><span class="attribute">xmlns</span><span>=</span><span class="attribute-value">&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">meta</span><span>&nbsp;</span><span class="attribute">http-equiv</span><span>=</span><span class="attribute-value">&quot;Content-Type&quot;</span><span>&nbsp;</span><span class="attribute">content</span><span>=</span><span class="attribute-value">&quot;text/html;&nbsp;charset=gb2312&quot;</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">title</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">title</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">link</span><span>&nbsp;</span><span class="attribute">href</span><span>=</span><span class="attribute-value">&quot;images/chatstyle.css&quot;</span><span>&nbsp;</span><span class="attribute">rel</span><span>=</span><span class="attribute-value">&quot;stylesheet&quot;</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">&quot;text/css&quot;</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">script</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">&quot;text/javascript&quot;</span><span>&nbsp;</span><span class="attribute">src</span><span>=</span><span class="attribute-value">&quot;js/display.js&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">script</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">script</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">&quot;text/javascript&quot;</span><span>&nbsp;</span><span class="attribute">src</span><span>=</span><span class="attribute-value">&quot;js/chat.js&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">script</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">script</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">&quot;text/javascript&quot;</span><span>&nbsp;</span><span class="attribute">src</span><span>=</span><span class="attribute-value">&quot;js/tw-sack.js&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">script</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;/</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">body</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">&quot;zt&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">div</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">&quot;loadifo&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">div</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span></span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">&quot;outs&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">&quot;outmain&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">&quot;chatmain&quot;</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">div</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">div</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">div</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span></span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">&quot;in&quot;</span><span class="tag">&gt;</span><span>昵称: &nbsp;&nbsp;</span></li>
    <li class=""

相关推荐

    jsp+ajax聊天室

    【jsp+ajax聊天室】是一种基于JavaServer Pages (JSP) 和 Asynchronous JavaScript and XML (AJAX) 技术实现的在线实时交流平台。JSP是服务器端的技术,用于生成动态网页,而AJAX则是一种在不刷新整个页面的情况下与...

    基于JSP+Ajax+MyEclipse 2015 Java聊天室软件源码+说明文档.zip

    基于JSP+Ajax+MyEclipse 2015 Java聊天室软件源码+说明文档 通过本课程设计的实践及其前后的准备与总结,复习、领会、巩固和运用软件工程课堂上所学的软件开发方法和知识,以此来完成Java聊天室的分析、设计、编码、...

    JSP + AJAX 的聊天室

    实现JSP + AJAX聊天室的关键技术点包括: 1. **AJAX请求**:使用JavaScript的XMLHttpRequest对象发起AJAX请求,向服务器发送用户输入的信息,获取服务器返回的新消息。 2. **JSON数据交换**:通常,服务器会将接收...

    JSP+AJAX华丽界面聊天室

    【JSP+AJAX华丽界面聊天室】是一个利用Java服务器页面(JSP)技术和异步JavaScript及XML(AJAX)技术构建的实时交互系统。它以其美观的英文界面和实用性吸引了用户。在这个项目中,我们将深入探讨JSP与AJAX在创建...

    jsp+ajax 无刷新聊天室

    【jsp+ajax 无刷新聊天室】是一种基于JavaServer Pages(JSP)技术和Ajax(Asynchronous JavaScript and XML)技术实现的在线实时交流平台。在这个聊天室中,用户无需手动刷新页面即可实时查看新消息,提高了用户...

    JSP+AJAX开发的聊天室(毕业设计)

    JSP+AJAX开发的网络聊天室,川大学生的毕业设计作品,配置好JSP环境就可以运行。用到了Ajax、struts、spring等,用PostgreSQL实现的,但是在平台上转换很简单,只需要修改application.xml里面的数据库源便可,希望对...

    一个简单的jsp聊天室(ajax技术)

    【标题】:“一个简单的jsp聊天室(ajax技术)” 在这个项目中,我们探索了一个基于JSP和AJAX技术实现的简单聊天室。JSP(JavaServer Pages)是用于创建动态网页的技术,它允许开发者在HTML代码中嵌入Java代码,...

    新版JSP+JQUERY+AJAX+Mysql聊天室小程序JASChatWeb1.0

    JASChatWeb 网页聊天室 1.0版--群聊+私聊+贴图 预览 http://ww1.sinaimg.cn/large/560ce489gw1dhm3ju5uxgj.jpg 经过多人 多浏览器测试,效果良好 实现了各种聊天常用功能 (1)群聊 (2)私聊 私聊窗口可拖动关闭 ...

    Jsp+ajax 在线聊天室

    【Jsp+Ajax 在线聊天室】是一款使用Java技术栈,结合JSP和Ajax实现的简单在线交流平台。这个项目适合初学者进行实践,以增强对Web开发的理解,特别是对于那些正在学习Java的大一大二学生而言,是理想的实训项目。在...

    jsp无刷新聊天室(jsp+ajax)

    【jsp无刷新聊天室(jsp+ajax)】项目是一个典型的Web应用示例,它利用了JavaServer Pages(JSP)技术和Ajax(异步JavaScript和XML)来实现一个无需页面刷新的实时聊天功能。在这个项目中,用户可以在聊天室中发送...

    JSP+AJAX华丽界面聊天室(jQuery框架)

    【JSP+AJAX华丽界面聊天室】是一个利用JavaServer Pages(JSP)技术和AJAX(Asynchronous JavaScript and XML)动态网页技术构建的实时交互应用。在这个项目中,开发人员选择了jQuery作为AJAX的框架,因为jQuery简化...

    JSP+Application聊天室

    **JSP+Application聊天室详解** 在Web开发领域,构建实时交流平台如聊天室是一项常见的需求。本项目“JSP+Application聊天室”提供了一个基于Java Server Pages (JSP) 技术和Application对象实现的实例,让我们深入...

    jsp+ajax实现简单聊天室

    - **index.jsp**:聊天室的主页面,可能包含AJAX调用的JavaScript代码以及用户界面元素。 - **ChatServlet.java**或类似的Java类:处理AJAX请求,如接收新消息、发送消息等。 - **MessageBean.java**:可能是一个...

    ajax无刷新聊天室源码--jsp版

    综上所述,"ajax无刷新聊天室源码--jsp版"涵盖了Ajax技术、JSP编程、Servlet交互、数据库操作等多个核心知识点,对于学习JavaWeb开发和理解前后端交互机制有着重要的实践意义。通过深入研究这个项目,开发者不仅可以...

    简单的Ajax聊天室样例(servlet+jsp)

    【Ajax聊天室】是一个基于Java Web技术实现的简单交互式应用,主要利用了Servlet、JSP和Ajax技术。这个小例子展示了如何通过Ajax实现在不刷新整个页面的情况下更新内容,提供了一个基本的在线聊天功能。 1. **...

    jquery+jsp+mysql聊天室

    在聊天室中,JSP主要负责处理来自客户端的Ajax请求,执行业务逻辑,如验证用户身份、存储或检索聊天记录。JSP还可以动态生成HTML代码,将接收到的新消息插入到聊天窗口,保持页面的实时更新。 MySQL是一个流行的...

Global site tag (gtag.js) - Google Analytics