If a user logged in a web application he/she can operate the browser back button to go to the previous page
But when he logged out he should not go to previous stage when he click the browser back button
Actually it will happen by storing the browser cache , when the user click the back button the request will not send to server, but the user can see the previous page details in the browser,
this can be avoid by not storing the browser cache
How can we do this ...We can do it by FilterConcept
I did it in use of JSF 2.2 with primefaces 3.5
Step 1 :
Step 2 :
Create no-cache code and place it in doFilter method
if(!httpServletRequest.getRequestURI().startsWith(httpServletRequest.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER))
{
httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
httpServletResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0.
httpServletResponse.setDateHeader("Expires", 0); // Proxies.
}
That s it...!!
Ref : http://stackoverflow.com/questions/10305718/avoid-back-button-on-jsf-web-application/18605642#comment27384547_10305799
But when he logged out he should not go to previous stage when he click the browser back button
Actually it will happen by storing the browser cache , when the user click the back button the request will not send to server, but the user can see the previous page details in the browser,
this can be avoid by not storing the browser cache
How can we do this ...We can do it by FilterConcept
I did it in use of JSF 2.2 with primefaces 3.5
Step 1 :
- Create JSF pages
- Create web.xml , do the necessary configurations
- Create faces-config.xml to map the managed bean classes
- Create Filter class as like i defined in this post http://javaannals.blogspot.in/2013/09/session-management-in-jsf.html
Step 2 :
Create no-cache code and place it in doFilter method
if(!httpServletRequest.getRequestURI().startsWith(httpServletRequest.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER))
{
httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
httpServletResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0.
httpServletResponse.setDateHeader("Expires", 0); // Proxies.
}
That s it...!!
Ref : http://stackoverflow.com/questions/10305718/avoid-back-button-on-jsf-web-application/18605642#comment27384547_10305799
Comments
Post a Comment