Im using Mojarra 2.1.3, NetBeans 7.0.1, Primefaces 3.2.
I have a few dynamic xhtml pages backed by ViewScoped backing beans in my application. Each of the pages has p:dataTable which display List<> from the backing bean. The problem occurs when a user navigate to a different page with the details of each item in the datatable. Upon browing the detail information, a user will most likely hit on the browser back button to return to the list. And so I implemented a filter like this in my application.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) request;
HttpServletResponse httpRes = (HttpServletResponse) response;
if (!httpReq.getRequestURI().startsWith(httpReq.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources (CSS/JS/Images/etc)
httpRes.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
httpRes.setHeader("Pragma", "no-cache"); // HTTP 1.0.
httpRes.setDateHeader("Expires", 0); // Proxies.
}
chain.doFilter(request, response);
}
But I have one problem, as explained here: How to move user to timeout page when session expires, if user click on browser back button the browser should instead send a fullworthy fresh HTTP request to the server.
But in my case it didn't. I see instead the ubiquituous Webpage has expired page which is in my opinion not a user friendly experience. What I want is NOT for it to load from browser cache but instead create a fresh request to the server and display the right page (Not the Webpage has Expired Page). Is it possible.
Please help. Thanks a lot.