如何获取实现CometProcessor接口的servlet的请求以通过过滤器 [英] How do I get the requests for a servlet implementing CometProcessor interface to pass through a filter

查看:283
本文介绍了如何获取实现CometProcessor接口的servlet的请求以通过过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个servlet实现 CometProcessor 并且我正在尝试使到达此servlet的请求通过过滤器。在web.xml下指定servlet不会使servlet请求通过过滤器。我还尝试实现CometFilter,并在web.xml中的下指定了实现CometProcessor的servlet。
我收到以下错误-

I have a servlet implementing CometProcessor and I am trying to get the requests coming to this servlet to pass through a filter. Specifying the servlet in web.xml under does not make the requests to the servlet to pass through the filter. I also tried implementing CometFilter and specified the servlet implementing CometProcessor in web.xml under . I get the following error -

Jan 29, 2013 12:10:04 PM org.apache.catalina.connector.CoyoteAdapter service - SEVERE: An exception or error occurred in the container during the request processing
java.lang.NullPointerException
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:430)
    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:356)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


推荐答案

感谢您的输入,我发现我要去哪里了。
我在实现CometFilter时犯了一个错误。我阅读了CometFilter类本身中的文档,发现我需要实现doFilterEvent方法而不是doFilter方法。现在,它的工作正常,并向实现CometProcessor的servlet的请求传递到此过滤器。

Thanks for your inputs, I found out where I am going wrong. I had made a mistake in implementing CometFilter. I read the documentation present in the CometFilter class itself and found that I need to implement doFilterEvent method and not doFilter method. Now its working fine and requests to the servlet implementing CometProcessor are being passed to this filter.

这篇关于如何获取实现CometProcessor接口的servlet的请求以通过过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆