<%@ page import="java.util.*"%>
<%!
//\u4E00\u4E9B\u5E38\u7528\u7684\u51FD\u6570
int maxMessage=100;//\u670D\u52A1\u5668\u8BB0\u5F55\u7684\u6700\u5927\u4FE1\u606F\u6570
int lessMessage=50;//\u8D85\u8FC7\u6700\u5927\u4FE1\u606F\u6570\u540E\uFF0C\u4FDD\u7559\u7684\u4FE1\u606F\u6570

public String getStr(String str)//\u8F6C\u6362\u5B57\u7B26\uFF0C\u907F\u514D\u8F93\u51FA\u4E71\u7801
{
	try
	{
		String temp_p=str;
		byte[] temp_t=temp_p.getBytes("ISO8859-1");
		String temp=new String(temp_t);
		return temp;
	}
	catch(Exception e)
	{

	}
	return null;
}

public void addToChatmsg(String msg){//\u589E\u52A0\u4E00\u6761\u804A\u5929\u8BB0\u5F55
		Vector chatmsg;
		if(getServletContext().getAttribute("chatmsg")==null){
			chatmsg=new Vector();
		}
		else{
			chatmsg=(Vector)getServletContext().getAttribute("chatmsg");
			}
        chatmsg.addElement(msg);
		if(chatmsg.size()>maxMessage){
		for(int j=chatmsg.size()-lessMessage-1;j>=0;j--)
			chatmsg.removeElementAt(j);
         }
        getServletContext().setAttribute("chatmsg",chatmsg);
}

public boolean isOnline(String username){//\u5224\u65AD\u7528\u6237\u662F\u5426\u5728\u7EBF
	if(getServletContext().getAttribute(username)==null){
		return false;
	}
	return true;
}
%>