判断是否登录的拦截器SessionFilter

需要写个拦截器,当用户没有登录的时候某些页面是不能访问的
用法将需要登录后访问的文件全部放在一个文件夹中,这里是logined文件夹

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

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 com.tlt.app.bean.Useraccount;
import com.tlt.app.util.Constants;

public class SessionFilter implements Filter{
	private List list = new ArrayList();
	
	public void destroy() {
		// TODO Auto-generated method stub
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		// TODO Auto-generated method stub
		String path=((HttpServletRequest)request).getServletPath();
//		System.out.println("path="+path);
		for(int i=0;i


可以使用多个文件夹,只需要将中的值之间用“,”隔开。


		sessionFilter
		com.tlt.app.filter.SessionFilter
		
			include
			logined
		
	
	
		sessionFilter
		/*
	

你可能感兴趣的:(Servlet,Java,Bean,XML)