`
tomEnjoy
  • 浏览: 142208 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

配置tomcat支持comet

    博客分类:
  • java
阅读更多
使用 Java 实现 Comet 风格的 Web 应用 实现 Servlet 3.0 规范
http://www.ibm.com/developerworks/cn/web/wa-cometjava/
通过 Tomcat Advanced I/O 获得高性能的 Ajax
http://www.ibm.com/developerworks/cn/web/wa-aj-hiperform/

在参考上面两篇文章配置tomcat支持comet时遇到一些问题,现总结如下:
1.tomcat官方明确指明实现异步的IO需要APR或NIO的支持,我在这里是配置了APR。(IMPORTANT NOTE: Usage of these features requires using the APR or NIO HTTP connectors. The classic java.io HTTP connector and the AJP connectors do not support them.)
直接去http://tomcat.apache.org/tomcat-6.0-doc/apr.html下载tcnative-1.dll放在bin目录下即可。
2.需要明确在项目里引用catalina.jar包,该包在tomcat的lib目录下。
3.为避免tomcat重复加载catalina.jar,我们在server.xml里配置context如下:
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
    <Context path="/mis2011">
	<Loader delegate="true" />
	<Resource name="mis2011" auth="Container" type="javax.sql.DataSource"
		username="root"
		password=""
		driverClassName="com.mysql.jdbc.Driver"
		url="jdbc:mysql://localhost:3306/..."
		maxActive="30"
		maxIdle="5"
		maxWait="50"
		minEvictableIdleTimeMillis="4000"
		timeBetweenEvictionRunsMillis="5000"
	/>
    </Context>
</host>

3.按上面第一篇文章的介绍配置Servlet即可。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics