Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3856094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:52:37+00:00 2026-05-19T17:52:37+00:00

I am seeing a similar issue as mentioned in this question – https://stackoverflow.com/questions/1495390/how-do-i-invalidate-a-session-in-jsf .

  • 0

I am seeing a similar issue as mentioned in this question – https://stackoverflow.com/questions/1495390/how-do-i-invalidate-a-session-in-jsf.

I have a session scoped LoginBean, which have an action logout as #

    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    HttpSession session = (HttpSession) ec.getSession(false);
    HttpServletResponse response = (HttpServletResponse) ec.getResponse();

    // remove cookies
    response.addCookie(facade.removeCookie(((HttpServletRequest)ec.getRequest()).getCookies()));
    // check what we have in sessionMap
    System.out.println(ec.getSessionMap());
    // remove attribute
    session.removeAttribute("XYZ");

    // invalidate session
    if (session != null) {
        System.out.println("invalidating session");
        session.invalidate();
    }
    // see what is there in session map
    System.out.println(ec.getSessionMap());

It almost work fine.

Output #

{xyzBean=com.xyz.bean.XYZBean@46f046f0,... }
invalidating session
{}

The sessionMap being empty, means there are no session scope beans. However, after logout action it redirects to another same page. Login being a layer on same page. I see that fragment jsps still have showing old data.

I am not removing JSESSIONID in facade.removeCookie. It removes some other cookies related to user.

Any help would be appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:52:38+00:00Added an answer on May 19, 2026 at 5:52 pm

    You’re likely viewing a page which is been served from browser cache. You need to add HTTP response headers which instructs the webbrowser to not cache the dynamic pages. You can do this with a javax.servlet.Filter which is mapped on an <url-pattern> of interest, e.g. *.jsf or something and does the following job in doFilter() method:

    HttpServletResponse httpResponse = (HttpServletResponse) response;
    httpResponse.setHeader("Cache-Control", "no-cache,no-store,must-revalidate"); // HTTP 1.1
    httpResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0
    httpResponse.setDateHeader("Expires", 0); // Proxies.
    chain.doFilter(request, response);
    

    Don’t forget to clear the browser cache before testing 😉


    Unrelated to the problem, the if (session != null) nullcheck in your code is superfluous since session can never be null when it reaches that nullcheck. If it was null, it would have thrown a NullPointerException at the removeAttribute() call and thus never reach the nullcheck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe seeing the issue would help you all a little: https://ws.onehub.com/files/nzvrbj4s Screen Shots: https://ws.onehub.com/files/9rw3li12
I am having an issue similar to this question: Problem with WCF and Multiple
I've been asking similar questions here today, but I'm seeing I think the issue
I know there is this question that is very similar, but I wanted to
I'm seeing a rendering issue for a 2px dotted border similar to CSS dotted
I've checked out a few of the stackoverflow questions and there are similar questions,
I've got an issue similar to this one: iPad/iPhone browser crashing when loading images
Seeing various locking related question and (almost) always finding the 'loop because of spurious
I have been seeing this a lot lately and I am unable to find
We've been seeing this problem for a while now and I'm really trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.