java - doFilter() not working for pages access restrictions -


i used balusc code implement filter class;

@webfilter("/manager/faces/*") public class authorizationfilter implements filter {  @override public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws servletexception, ioexception {         httpservletrequest req = (httpservletrequest) request;     usersession auth = (usersession) req.getsession().getattribute("usersession");      if (auth != null && auth.isloggedin()) {         chain.dofilter(request, response);     } else {         httpservletresponse res = (httpservletresponse) response;         res.sendredirect(req.getcontextpath() + "/index.xhtml");     } } 

i have usersession class login(), logout(), isloggedin() methods, , user field checked if null in isloggedin().

first: code correct?:

usersession auth = (usersession) req.getsession().getattribute("usersession"); 

my index page is:

/manager/faces/index.xhtml

and when login have access pages, it's not working.

even system.out.println in dofilter methods don't display. have call dofilter() somewhere?


Comments