In a PhaseListener, at which PhaseId should I check for a session timeout?
In a PhaseListener, at which PhaseId should I check for a session timeout?
Right now, I check after RENDER_RESPONSE.
In Netbeans 5.0, I can debug the PhaseListener and it reaches RENDER_RESPONSE and then steps into the logic to check for a session.
I set my session timeout at one minute.
After I wait over a minute, I click on a button on the page, nothing happens, I am not redirected nor is there any information in the server.log for Sun Java System Application Server 8.2.
Thoughts or any suggestions are greatly appreciated.
Thanks,
--Todd
I have the following settings:
web.xml
<session-config>
<session-timeout>1</session-timeout>
</session-config>
faces-config.xml
<navigation-rule>
<navigation-case>
<from-outcome>sessionExpired</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<lifecycle>
<phase-listener>com.TimeoutListener</phase-listener>
</lifecycle>
Class
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpSession;
publicclass TimeoutListenerimplements PhaseListener{
public PhaseId getPhaseId(){
return PhaseId.ANY_PHASE;
}
publicvoid beforePhase(PhaseEvent e){
if(e.getPhaseId()== PhaseId.RENDER_RESPONSE){
FacesContext facesContext = e.getFacesContext();
HttpSession sessionx = (HttpSession)facesContext
.getExternalContext().getSession(false);
if (sessionx.getId() ==""){
facesContext.getApplication().getNavigationHandler()
.handleNavigation(facesContext,"","sessionExpired" );
}
}
}
publicvoid afterPhase(PhaseEvent e){
//System.out.println("AFTER " + e.getPhaseId() + " begins");
}
}

