Unable to logout using FacesContext

Discussions

Web tier: servlets, JSP, Web frameworks: Unable to logout using FacesContext

  1. Unable to logout using FacesContext (3 messages)

    I am working on Rational Application Developer which uses WAS 6.0. We are using JSF. Our application is using server side security. I am an absolute newbie to JSF technology. My problem is, I am not able make the Logout link work. I have created a simple Logout servlet which tries to invalidate the session and redirect the user to login page. For invalidating the session first I have tried using

    HttpSession session = request.getSession();
    session.invalidate();

    Which obviously didn't worked.

    Then I have tried

    FacesContext context = FacesContext.getCurrentInstance();

    HttpSession session = (HttpSession) context.getExternalContext().getSession(false);

    session.invalidate();

    Which, also didn't worked. As the FacesContext.getCurrentInstance(); is returning null. I am clueless about it. Why this is not working. Can anybody help me out in sorting this problem. A timely help is always appreciated.
  2. Where are you calling the code that gets to the faces context?
  3. Hi,

    I have written a Logout servlet where I am trying to use faces context in order to invalidate the session. Although I am able to make the logout functionality work using the standard WAS logout servlet. But the original problem is still there. But it's not hampering my progress.

    Thanks,
    Charukant
  4. You cannot get(/use) FacesContext inside another servlet
    FacesServet.

    Try use for logout jsf facilities (jsp-jsf views & managed beans) of create some kind of Filter or Listener that can actually interact with FacesServlet.

    Or may be you just need learn bit more about technologies you are using