I'm using a Glassfish 4 server with a JSF2 framework.
My problem
When calling the response.sendRedirect method, I'm having a IllegalStateException.
I don't have a single clue why this exception was raised.
The context
For every xhtml page, I have this method called to check if the user is still logged in.
<body id="body" onload="#{utilisateurBean.isUserLoggedIn()}">
The method
public void isUserLoggedIn() throws IOException {
if(this.user == null){
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.sendRedirect("Project/accueil/index.xhtml");
}
}
Exception
Infos: Exception when handling error trying to reset the response.
java.lang.IllegalStateException
Or
Avertissement: Servlet.service() for servlet session.AppExceptionHandler threw exception
java.lang.IllegalStateException: Cannot forward after response has been committed
I don't know why the response is being commited.
Thank for your help :)