public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)arg0;
request.setCharacterEncoding("gb2312");
HttpServletResponse response = (HttpServletResponse)arg1;
String RequestUri = request.getRequestURI();
HttpSession session = request.getSession();
Object obj = session.getAttribute("user");
if(obj == null 
&& !RequestUri.endsWith("/index.jsp")){
System.out.println("非法操作,被过滤!");
response.sendRedirect(request.getContextPath()+"/"+this.forwradPath);
return;
}
arg2.doFilter(arg0, arg1);
} public void init(FilterConfig arg0) throws ServletException { this.filterConfig = arg0;
this.forwradPath = filterConfig.getInitParameter("forwradPath"); }
---------------------------------------------------
  <filter>
   <filter-name>webFilter</filter-name>
   <filter-class>com.hang.yinhe.web.UserLoginFilter</filter-class>
   <init-param>
   <param-name>forwardpath</param-name>
   <param-value>index.jsp</param-value>
   </init-param>
  </filter>
  <filter-mapping>
   <filter-name>webFilter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
   <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
为什么总是死循环啊?