How can I stop caching of pages in browser using Servlets?
I want that session should expire if I press back button of browser when i am logged in.
How can I stop caching of pages in browser using Servlets?
I want that session should expire if I press back button of browser when i am logged in.
To permanently disable cache.
Clearing the client cache would not expire session immediately,but clears session cookies in the browser. To make the session expire immediately, you need to explicitly specify in server side jsp or servlet.
If you get a HttpServletResponse (implementation) object for the request you can send HTTP headers that will encourage browsers not to cache the content you send them.
See the documentation for HttpServletResponse and HttpServletResponseWrapper. In case you need to read up on cache control headers in HTTP, check this out.