Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Cearing browser Cache using Servlet  RSS feed

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I would like to clear the cache memory of the browser using servlet by which it will not allow the visitor to access the previous page(The User Account Area Page) after logout.
I tried it using the following block of code, but unfortunately its not working. I mean only logout is working properly...

Please help me out.

//Here is the code
HttpSession session=request.getSession(false);

response.setContentType("text/html;charset=UTF-8");
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setHeader("Expires","0");
if(session.getAttribute("IDPassword")!=null)
{
session.invalidate();
response.sendRedirect("SuccessfulLogout.jsp");
//request.getRequestDispatcher("SuccessfulLogout.jsp").forward(request, response);
}

Thanking you in advance...

Amitav Anand
 
Author and ninkuma
Marshal
Posts: 66810
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't cause the browser cache to clear. You can suggest to the browser that it not cache your page, as you are doing, but that's the extent of what you can do.
 
Amitav Anand
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your immediate response.
I think you are right as far as the browser cache memory is concerned.

In fact I have written the code that is supposed to prevent the server output from getting stored in the browser cache.

But its not even doing that....

Please guide me if anything wrong out there in the code or the steps for the same.


Thanks and Regards.

Amitav Anand
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!