hello i am using prettyfaces jsf2.0 i ve created a filter which is checking every request whether user is logged in or not
@WebFilter(urlPatterns= {"*.xhtml"} , dispatcherTypes = {DispatcherType.REQUEST})
public class Authentication implements Filter {
@Override
public void init(FilterConfig config) throws ServletException {
System.out.println("[Authentication Filter] : init Method");
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession(false);
PrettyContext context = PrettyContext.getCurrentInstance(request);
if (!(context.getCurrentMapping().getId().equals("login")) && (session == null || session.getAttribute("username") == null)) {
{
response.sendRedirect(request.getContextPath()+"/login");
}
else {
chain.doFilter(req, res); // Logged-in user found, so just continue request.
}
@Override
public void destroy() {}
}
when i started tomcat server it load login.xhtml page URL is showing in address bar //localhost:8080/MyApp/login in login.xhtml i ve form with user name and password fields
when i submit form using
<p:commandButton ajax="false" value="Login" action="pretty:loggedin" />
and when i get values in action class, the values are null there and when i print system.out.println loggin in filter it looks like two URL are requesting 1. /login 2. /loggedin thats y values are getting null there. any solution please thanks in advance.