Difference between Filter and Listener in Servlet (Java EE)

前端 未结 10 1050
有刺的猬
有刺的猬 2020-12-22 19:05

There are Filters and Listeners functionality in Servlet. I want to know exact difference between Filter and Listener.

10条回答
  •  时光说笑
    2020-12-22 19:14

    Servlet Filter is used for monitoring request and response from client to the servlet, or to modify the request and response, or to audit and log.

    Servlet Listener is used for listening to events in a web containers, such as when you create a session, or place an attribute in an session or if you passivate and activate in another container, to subscribe to these events you can configure listener in web.xml, for example HttpSessionListener.

提交回复
热议问题