Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客户端的请求和 HTTP 服务器上的数据库或应用程序之间的中间层。

使用 Servlet,您可以收集来自网页表单的用户输入,呈现来自数据库或者其他源的记录,还可以动态创建网页。

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.

Servlet Filter

Filter is an object which transform the request and response (header as well as content).
Servlet Filter is used for manipulating the request and response from client to the servlet, or to modify the request and response, or to audit and log. Filters are called on a per-request basis and listeners are not. Filters have access to request object and listeners don’t. Filters can perform many different types of functions. We’ll discuss examples of the italicized items in this paper:

  • Authentication-Blocking requests based on user identity.
  • Logging and auditing-Tracking users of a web application.
  • Image conversion-Scaling maps, and so on.
  • Data compression-Making downloads smaller.
  • Localization-Targeting the request and response to a particular locale.
  • XSL/T transformations of XML content-Targeting web application responses to more that one type of client.

Servlet Listener

You can monitor and react to events in a servlet’s life cycle by defining listener objects whose methods get invoked when life cycle events occur. Servlet Listener is used for listening various events inside a web containers, such as when you create a session, or place an attribute in a session or if you passivate and activate in another container, to manipulate these events you can configure listener in web.xml, for example HttpSessionListener. Below a list of provided Listener classes:

    • HttpSessionAttributeListener
    • HttpSessionBindingListener
    • HttpSessionListener
    • ServletContextAttributeListener
    • ServletContextListener

filter and listener的更多相关文章

  1. Servlet、Filter、Listener、Interceptor

    首先,JSP/Servlet规范中定义了Servlet.Filter.Listener这三种角色,并没有定义Interceptor这个角 色,Interceptor是某些MVC框架中的角色,比如Str ...

  2. servlet、filter、listener、interceptor之间的区别和联系

    一.概念 1.servlet:servlet是一种运行服务器端的java应用程序,具有独立于平台和协议的特性,并且可以动态的生成web页面,它工作在客户端请求与服务器响应的中间层. 2.filter: ...

  3. j2ee Servlet、Filter、Listener

    首先,JSP/Servlet规范中定义了Servlet.Filter.Listener这三种角色,并没有定义Interceptor这个角色,Interceptor是某些MVC框架中的角色,比如Stru ...

  4. JavaWeb之Filter、Listener

    昨天和大家介绍了一下JSON的用法,其实JSON中主要是用来和数据库交互数据的.今天给大家讲解的是Filter和Listener的用法. 一.Listenner监听器 1.1.定义 Javaweb中的 ...

  5. Filter、Listener 学习总结

    今天我们来介绍 Filter.Listener 这两个模块一些简单的知识和应用,接下来我们开始我们的正题 ! 1. Filter(过滤器) 1.1 对 Servlet 容器调用 Servlet 的过程 ...

  6. 基于注解的SpringMVC添加其他的Servlet、Filter以及Listener

    我们可以在AbstractAnnotationConfigDispatcherServletInitializer的实现类中重写onStartup(ServletContext servletCont ...

  7. SpringBoot中使用Servlet,Filter,Listener

    项目最近在替换之前陈旧的框架,改用SpringBoot进行重构,初接触,暂时还没有用到Servlet,Filter,Listener的地方,但在之前回顾Servlet的生命周期时,https://ww ...

  8. SpringBoot 配置 Servlet、Filter、Listener

    SpringBoot 配置 Servlet.Filter.Listener 在SpringBoot应用中,嵌入式的 Servlet 3.0+ 容器不会直接使用 ServletContainerInit ...

  9. 【Web】servlet、filter和listener

    一般地,servlet.filter.listener是配置到web.xml中(web.xml 的加载顺序是:context-param -> listener -> filter -&g ...

  10. 【SpringBoot】SpringBoot拦截器实战和 Servlet3.0自定义Filter、Listener

    =================6.SpringBoot拦截器实战和 Servlet3.0自定义Filter.Listener ============ 1.深入SpringBoot2.x过滤器Fi ...

随机推荐

  1. Python学习笔记之字符串

    一.字符串格式化 >>> format="Hello,%s. %s enough for ya?" >>> values=('World','H ...

  2. SAP常用命令及BASIS操作

    Pfcg         角色,权限参数文件配置Su53        查看权限对象  st01  跟踪St22         看dump,以分析错误  eg.找到ABAP程序出错的地方,找出fou ...

  3. minicom的安装与配置

    分类: LINUX     如果项目中使用的bootloader为 u-boot,那么在用minicom向目标板传送kernel时 会发生一些错误.故若您使用的是u-boot,建议您使用kermit, ...

  4. CodeForces 686C-Robbers' watch

    题意: 一个电子手表的示数是7进制的,现在告诉你一天有多少小时和一小时有多少分钟,问你一天里有多少个时刻,这个表上显示的数字各不相同. 分析: 先找出表上有多少位数字,再按位dfs,看最后得到的数是否 ...

  5. hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏

    huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...

  6. Python开发入门与实战5-django模型

    5.Django模型 在当今的Web 应用中,主观逻辑经常牵涉到与数据库的交互,数据库驱动网站.在后台连接数据库服务器,从中取出一些数据,然后在 Web 页面用各种各样的格式展示这些数据.这个网站也可 ...

  7. Goldengate 12.2新特性-自描述的队列文件

    OGG12.2中最大的变化之一就是队列文件是自描述的,意思是不再担心以前版本中,表结构异构的情况,也不再需要defgen生成定义文件,以及不再使用assumeTargetDefs或SourceDefs ...

  8. HDU 4717 The Moving Points (三分法)

    题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...

  9. jQuery固定浮动侧边栏(jQuery fixed Sidebar)

    这个功能现在应用的非常普遍,如果页面比较高,当滚动条拖到页面的下面的时候,侧边栏会出现一个固定跟随浏览器的DIV框,现思路是这样的:首先获取需要跟随的DIV距离页面顶部的距离,然后判断,当浏览器滚动的 ...

  10. Ztree使用笔记

    在项目中需要用到树,使用了Ztree.(官网地址:http://www.treejs.cn/v3/main.php#_zTreeInfo,介绍很详细,有API,有demo) 1.初始化树:   $.f ...