Maybe this is not the right place to do this question, if not I'm sorry, but maybe someone could help me.
First I created a Filter to control access page:
Code: Select all
@WebFilter(filterName = "AppAuthFilter", urlPatterns = {"*.jsf"})
public class AppAuthFilter extends AppController implements Filter {
...
...
}
So I search a little bit and find about PhaseListener and sounds really better because it only pass one time for each page request.
But when I was using the Filter, when the page is in maintenance-mode for example, I just send a error:
Code: Select all
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
I tried like this, inside the afterPhase method.
Code: Select all
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
So what is the best practice to do this?
Thanks in advance.