package servlet.filter;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class CheckLoginFilter implements Filter {
	FilterConfig config = null;

	public void init(FilterConfig arg0) throws ServletException {
		this.config = arg0;
	}
	
	public void doFilter(ServletRequest arg0, ServletResponse arg1,
			FilterChain arg2) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) arg0;
		HttpSession session = request.getSession(true);
		String islogin = (String) session.getAttribute("islogin");
		HttpServletResponse response = (HttpServletResponse) arg1;
		if (islogin == null || !islogin.equals("true")) {
			response.sendRedirect("../error.html");
		}
		arg2.doFilter(request, response);
	}

	public void destroy() {
		config = null;
	}
}
