Package com. common;
Import java. io. IOException;
Import java. util. Enumeration;
Import javax. servlet. Filter;
Import javax. servlet. FilterChain;
Import javax. servlet. FilterConfig;
Import javax. servlet. ServletException;
Import javax. servlet. ServletRequest;
Import javax. servlet. ServletResponse;
Import javax. servlet. http. HttpServletRequest;
Import javax. servlet. http. HttpServletResponse;
Import javax. servlet. http. HttpSession;
Public class SessionFilter implements Filter {
Private FilterConfig filterConfig;
Public void setFilterConfig (final FilterConfig filterConfig ){
This. filterConfig = filterConfig;
}
Public FilterConfig getFilterConfig (){
Return filterConfig;
}
Public void init (FilterConfig config) throws ServletException {
This. filterConfig = config;
}
Public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpSession session = req. getSession ();
String url = req. getRequestURI ();
Req. setCharacterEncoding ("UTF-8 ");
Response. setCharacterEncoding ("UTF-8 ");
If (session. getAttribute ("loginUser ")! = Null ){
Chain. doFilter (request, response );
} Else {
If (url. indexOf ("login. do ")! =-1
| Url. indexOf ("index. do ")! =-1
| Url. indexOf ("initMainLdapTree. do ")! =-1
| Url. indexOf ("indexMain. do ")! =-1
| Url. indexOf ("platData. do ")! =-1
| Url. indexOf ("resDownLoad. do ")! =-1
| Url. indexOf ("mainUrl. do ")! =-1
| Url. indexOf ("showNewsOfOne. do ")! =-1
| Url. indexOf ("showNewsList. do ")! =-1
| Url. indexOf ("user_Infor.do ")! =-1
| Url. indexOf ("initUserTree. do ")! =-1
| Url. indexOf ("queryCenBusi. do ")! =-1
| Url. indexOf ("queryUseBusiInMain. do ")! =-1
| Url. indexOf ("queryBusiInforForMain. do ")! =-1
| Url. indexOf ("lineData. do ")! =-1
| Url. indexOf ("queryLdapMainAttr. do ")! =-1
| Url. indexOf ("downLoadXml. do ")! =-1
| Url. indexOf ("resDown. do ")! =-1
| Url. indexOf ("selectUrl. do ")! =-1
| Url. indexOf ("initDepEmailTree. do ")! =-1
| Url. indexOf ("selDoorForm. do ")! =-1
| Url. indexOf ("selChaXun. do ")! =-1
| Url. indexOf ("selHeCha. do ")! =-1
| Url. indexOf ("selBiDui. do ")! =-1
| Url. indexOf ("shangBao. do ")! =-1
){
Chain. doFilter (request, response );
} Else {
Request. getRequestDispatcher ("/jsp/sessionError. jsp"). forward (request, response );
}
}
}
Public void destroy (){
This. filterConfig = null;
}
}