如何在WEB服务器端自动启动sock服务器程序?

用java写了一个sock服务器程序,用来接受客户端发送的数据,这个程序运行在WEB服务器,怎样让这个程序在WEB服务器服务启动时自动运行,在WEB服务停止时退出sock服务程序?
[90 byte] By [expeditioner] at [2008-5-2]
# 1
写个servlet 实现 implements ServletContextListener
web.xml 添加
<listener>
<listener-class></listener-class>
</listener>
waterborn-WaterBorn at 2007-10-14 > top of Msdn China Tech,Java,Web 开发...
# 2
怎样为这个类在web.xml设置参数?
我用<init-param vport='80'/>
是不是必须要写成servlet才行?

如果这个类只implements ServletContextListener
可以把参数写在web.xml中吗?什么格式?
expeditioner at 2007-10-14 > top of Msdn China Tech,Java,Web 开发...
# 3
参数问题解决了。
再问一下
如果想在web启动成功后运行一段程序如何处理?谢谢
expeditioner at 2007-10-14 > top of Msdn China Tech,Java,Web 开发...
# 4
用Listener
qiyadeng-。。。。。 at 2007-10-14 > top of Msdn China Tech,Java,Web 开发...