一个简单聊天室的问题,帮忙看一下
一、SpeakCountBean.java
package chatroom;
import java.util.*;
public class SpeakCountBean {
static int count;
public static void SpeakCountBean() {
count=0;
}
public static void setName(String name) {
count++;
}
public static int getSpeakCount() {
return count;
}
}
二、SpeakBean.java
package chatroom;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SpeakBean {
static String allSpeaking= new String( " ");
static String CookieName = new String( " ");
public SpeakBean() {
}
public static void setChat(String name,String speaking,
HttpServletResponse response) {
if (!name.equals( " ") && !speaking.equals( " "))
allSpeaking=allSpeaking+name+ "说: "+speaking+ ";
Cookie cookie = new Cookie( "name ",name);
response.addCookie(cookie);
}
public String getCookieName(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
if (cookies.length > 0)
{for (int i = 0; i < cookies.length; i++)
{Cookie requestcookie = cookies[i];
if (requestcookie.getName().equals( "name "))
CookieName = requestcookie.getValue();
}
}
return CookieName;
}
public String getAllSpeaking() {
return allSpeaking;
}
}
三、ChatRoom.java
package chatroom;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class ChatRoom extends HttpServlet {
&nbs