ServerContext context = ServerContextFactory.get();
//��ÿͻ�������chatҳ��script session������
Collection<ScriptSession> sessions = context.getScriptSessionsByPage(((ServerContext) ctx).getContextPath() + "/chat.jsp");
for (ScriptSession session : sessions) {
ScriptBuffer sb = new ScriptBuffer();
Date time = msg.getTime();
@SuppressWarnings("deprecation")
String s = time.getYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate() + " "
+ time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
//ִ��setMessage����
sb.appendScript("showMessage({msg: '")
.appendScript(msg.getMsg())
.appendScript("', time: '")
.appendScript(s)
.appendScript("'})");
System.out.println(sb.toString());
//ִ�пͻ���script session�������൱�������ִ��JavaScript����
//����ͻ�ִ�пͻ���������е�showMessage���������Ҵ���һ�������ȥ
session.addScript(sb);
}