public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; AuthenticationBean authBean = (AuthenticationBean) req.getSession().getAttribute("authBean"); boolean letGo = false; if ((authBean != null) && (authBean.getUserType().equals("student"))) { letGo = true; } if (letGo) { chain.doFilter(request, response); } else { resp.sendRedirect(req.getContextPath() + "/welcome.jsf"); } }