Solved

Clear Cache on JSP WEB PAGE

Posted on 2009-07-13
10
2,453 Views
Last Modified: 2012-05-07
Hi

I new to jsp and java but I need to know is there a way to my sure that when the user logout from the application that it clears the cache from the browser (FIREFox and IE). If there a script of meta tag to use that works 100%.

Also that values does not cache in my application. E.g. I have a link called Search Asset and i requires me to input a value e.g (NG123) and get my results. Now when I go to a second link called Transfer Asset and it populate the value automaticlly   (NG123). Is there a way on my jsp page to clear cache on every page
0
Comment
Question by:ablsysadmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
10 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 24840002
I don't know the Java code to do this exactly, but this is the C# code. It should just need to be converted. This will need to go on every page that you don't want cached.
System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddYears(-1));
System.Web.HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
System.Web.HttpContext.Current.Response.Cache.SetNoStore();
System.Web.HttpContext.Current.Response.Cache.SetNoServerCaching();
System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

Open in new window

0
 

Author Comment

by:ablsysadmin
ID: 24842429
Hi Expert

I am still new to java and do not know much about c#. Could you assit with javascript or java.
0
 
LVL 28

Expert Comment

by:strickdd
ID: 24842667
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ablsysadmin
ID: 24849236
Hi

I will have a look at it and provide you with feedback
0
 

Author Comment

by:ablsysadmin
ID: 24856764
Hi

I have placed tis in my LoginForm.jsp but when I log out and I want to log in back again I can still see that my username is cached
<%
//This is to disable caching
//There has to be a better way to do this
//See http://www.jguru.com/faq/view.jsp?EID=377&page=2 for details
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
response.setHeader("Cache-Control", "private, no-store, no-cache,must-revalidate, max-stale=0"); //HTTP 1.1
response.addHeader("Cache-Control", "post-check=0, pre-check=0"); //IE Specific
response.setHeader("Pragma","no-cache"); //HTTP 1.0
%>
<%
   response.setHeader( "Pragma", "no-cache" );
   response.setHeader( "Cache-Control", "no-cache" );
   response.setDateHeader( "Expires", 0 );
   
%>

Open in new window

0
 

Author Comment

by:ablsysadmin
ID: 24866969
Hi

I have placed  the following below in my logout page and it cleans my cookies, but my probem is that when loggin into the application the value cache still happend. What I tried yesterday changing my bean from session to request and it give me error and I had to change it back. Is there some assistance to this please

<% request.getSession().invalidate(); %>

0
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 125 total points
ID: 24916873
Simply add the cache control tags to your page[not to cache]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>No Cache </title>

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="01 Jan 1970 00:00:00 GMT">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

</head>
<body>

<% Hello!  The time is now <%= new java.util.Date() %>
</body>
</html>
0
 

Author Closing Comment

by:ablsysadmin
ID: 31602828
Excellent
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question