1
 <h:messages class="loginFailed" globalOnly="true" layout="table" /> 

I have this at the bottom of my login page. When the user fails to login it displays an error message. My problem is when they navigate to the registration page the error message is still there.

How do I get rid of this message.

DD.
  • 19,793
  • 49
  • 140
  • 237
  • 1
    can you post more code please to be able to help you? – aseychell May 24 '11 at 20:34
  • the rest of the code is kind of irrelevant. I have global messages tag and even if I navigate away from the page and come back the message is still there. – DD. May 24 '11 at 20:51
  • Is it the browser cache again? http://stackoverflow.com/questions/6115760/jsf-fields-of-my-backbean-are-not-cleaned-even-after-exiting-the-application – BalusC May 24 '11 at 20:59
  • I dont think so....I have a few login+registration pages and the error shows up on all of them. – DD. May 24 '11 at 21:12
  • Also after Ctrl+F5? Are you navigating by fullworthy GET requests or just re-rendering some include content by ajax? – BalusC May 24 '11 at 21:19

1 Answers1

2

It's definitely a browser cache issue. The pages are requested from the browser cache when navigating using the back button. I investigated the response headers on the site link you provided using Firebug and they indeed don't contain headers which instructs the browser to not cache the page.

Create a Filter which is mapped on an URL pattern of *.xhtml and does the following job in doFilter() method.

HttpServletResponse hsr = (HttpServletResponse) response;
hsr.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
hsr.setHeader("Pragma", "no-cache"); // HTTP 1.0.
hsr.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • is a filter really necessary? can't you do that with meta tags inside xhtml? – Kerem Baydoğan May 24 '11 at 22:08
  • Yes. And no, the meta tags are useful for local storage only. See also http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers/2068407#2068407 – BalusC May 24 '11 at 22:10