I have an authentication filter where I check if the session scoped bean is initialized or not. If it's null I would like to forward to login page.
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) {
UserBean ub = ((HttpServletRequest)request).getSession().getAttribute("userBean");
if(ub == null) {
request.getRequestDispatcher("/login.xhtml").forward(request, response);
return;
}
........
}
The problem with this code is that I get the login.xhtml page as xhtml, I mean the tags are not converted to html tags.
As a note: I want to use the forward
method because I don't want the URL with login.xhtml to be saved in browser history.