3)index.jsp 主页,可通过request.getCookes方法获取用户信息。
Servlet过滤器是一种java组件,它位于客户端和处理程序之间,能够对请求和响应进行检查以及修改。Servlet过滤器常用来完成一些通用的操作,例如统一字符集编码、字符的压缩和加密以及对访问路径的检查来实施安全控制。

1.当客户端对服务器资源发出请求时,服务器会根据应用配置文件设置的过滤规则进行检查,如果客户端的请求满足过滤规则,则对客户端请求进行拦截,对请求消息头和请求数据进行检查或改动,并依次通过过滤器链,最后把请求交给处理程序。
2.请求信息在过滤器链可以被修改,也可以根据条件不把请求发往处理程序,直接向客户端发回一个响应。
3.当处理程序完成了虽请求的处理后,响应信息将逐级逆向返回。同样在这个过程中,响应信息也可能被过滤器修改,从而完成一定的任务。
与过滤器相关的API包含了三个接口,分别是Filter、FilterChain和FilterConfig
所有的过滤器都要实现Filter接口。该接口定义了void destroy()、end of the chain.和void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
方法。
1.void destroy()
Called by the web container to indicate to a filter that it is being taken out of service. Servlet过滤器的初始化方法,Servlet容器创建Servlet过滤器实例后将调用这个方法。
2.void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. 用于完成实际的过滤操作,当客户端的请求满足过滤规则时,Servlet容器将调用过滤器的doFilter方法完成它想做的一切。
3.void init(FilterConfig filterConfig)
Called by the web container to indicate to a filter that it is being placed into service 当doFilter方法中的所有线程退出或超时时,容器将调用destroy方法来释放过滤器占有的所有资源,以此表明过滤器已结束服务。
A FilterChain is an object provided by the servlet container to the developer giving a view into the invocation chain of a filtered request for a resource. Filters use the FilterChain to invoke the next filter in the chain, or if the calling filter is the last filter in the chain, to invoke the resource at the end of the chain.用于访问过滤器链上的下一个过滤器。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-36808-19.html
1900对于退休老人来说正常生活肯定没问题的
越菲要哭了
是1888年