Hi! Many thanks. Perhaps I should start a new thread.
This is my situation.
I am using a servlet filter that uses the FacesContext. This is possible using the methods described (for example) here.
Here is some code:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
FacesContextBuilder builder = new FacesContextBuilder();
FacesContext facesContext = builder.getFacesContext(request, response);
Application application = facesContext.getApplication();
ELContext elContext = facesContext.getELContext();
SessionController sessionController = (SessionController) application.getELResolver().getValue(elContext, null, "sessionController");
User currentUser = sessionController.getCurrentUser();
if (currentUser == null)
Based on the value of currentUser I either call chain.doFilter(request, response) or send a redirect.
It seems that as soon as the JSFSession is created doFilter is called. So it's too late to enable redirects.
A solution that comes to mind is setting currentUser before JSFSession is created. To do this I would need to access the JSFUnit FacesContext before creating the JSFSession. Is this possible?
Again, thank you.
I don't know enough about your applicaiton to give a good answer.
What is the SessionController? Where is it getting the current user from?
I don't see why you need a FacesContext to get the current user. Isn't there another way?
If you are using standard JEE authentication then you can get the remote user from the HttpServletRequest.