<!--this file are used to init this web server-->
<!--writtten by fancy-->
<html>
<title>
初始化聊天室
</title>
<head>
</head>
<body>
<%@ page import="java.util.Vector" %>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.Date " %>
<%
//init the  chat msg
Vector chat1MsgVector=new Vector();
Vector chat2MsgVector=new Vector();chat1MsgVector.addElement("<font color='red' size='2'>欢迎来到未名聊天室1.</font><br>");
chat2MsgVector.addElement("<font color='red' size='2'>欢迎来到未名聊天室2.</font><br>");//the following code are used to init the welcome msggetServletContext().setAttribute("chat1Msg",chat1MsgVector);
getServletContext().setAttribute("chat2Msg",chat2MsgVector);
//*********************************************************************
//init the chat user list
Vector chat1User=new Vector();
Vector chat2User=new Vector();//fancy is the operator
chat1User.addElement("fancy");
chat2User.addElement("fancy");getServletContext().setAttribute("chat1User",chat1User);
getServletContext().setAttribute("chat2User",chat2User);
//*******************************************************************************//the following code are used to init the chat topic !!!getServletContext().setAttribute("chat1Topic","新青年");
getServletContext().setAttribute("chat2Topic","MM专用");
%><%
Hashtable userLife=new Hashtable();
Hashtable userIP=new Hashtable();
Date fancyTime=new Date();
String fancyIP="192.168.101.27";
userLife.put("fancy",new Long(fancyTime.getTime()));
userIP.put("fancy",fancyIP);
getServletContext().setAttribute("userLife",userLife);
getServletContext().setAttribute("userIP",userIP);
%>
</body>
</html>
上面是一个简单聊天室的初始化程序,使用了APPLICATION对象,我不知道把程序放在什么地方,怎么使TOMCAT启动时候生成APPLICATION对象??望高手赐教?另外谁有JSP做聊天室源码给我一个?
谢谢