Title: HttpSessionListener -->How to react, when Session is not valid anymore

Hi!

I have just implemented a HttpSessionListener to react on the event, when the session is not valid anymore.

Now I want to redirect the user to my login page again, when the session is timed out...

The Problem is, that the FacesContext is also null, when the session is timed out...
So how can I do a redirect, if I don't have a FacesContext?


So my listener looks like this:
public final class MyContextListener implements HttpSessionListener {

public void sessionCreated(HttpSessionEvent arg0) {
                // TODO Auto-generated method stub
               
        }

public void sessionDestroyed(HttpSessionEvent arg0) {
                System.out.println("SESSION ABGELAUFEN");
                               
                HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

                HttpServletResponse res =(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();

       
                try {
                        req.getRequestDispatcher("/logout.jsp").forward(req, res);
                }
                 catch (ServletException e2) {
                  e2.printStackTrace();
                } catch (IOException e2) {
                  e2.printStackTrace();
                 }             
        }
}


______________________________________________________________________ Diese Nachricht ist fuer die MAGNA STEYR Fahrzeugtechnik AG & Co KG rechtsunverbindlich! - This message is not legally binding upon MAGNA STEYR Fahrzeugtechnik AG & Co KG! This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify your system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ______________________________________________________________________

Reply via email to