Solved

back button or refresh page onload

Posted on 2004-04-28
6
33,496 Views
Last Modified: 2011-08-18
hi,
Does anybody know how to detect when the user click on the back button to go back to the previous page?
Or a way to refresh a jsp page whenever it's loaded?

Thank you. :)
0
Comment
Question by:F1stu
[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
6 Comments
 
LVL 7

Accepted Solution

by:
mark-b earned 125 total points
ID: 10943492
Add these four lines at the top of the JSP:

response.setHeader( "Expires", "Sat, 6 May 1995 12:00:00 GMT" );
     
// set standard HTTP/1.1 no-cache headers
response.setHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );

// set IE extended HTTP/1.1 no-cache headers
response.addHeader( "Cache-Control", "post-check=0, pre-check=0" );

// set standard HTTP/1.0 no-cache header
response.setHeader( "Pragma", "no-cache" );

That *should* force the user agent to reload the page when it is hit.

-Mark
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 10943519
Do you have this in your <HEAD> part of HTML coding...

<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="cache-control" content="no-cache"/>

You can use a META tag with an HTTP-EQUIV attribute to control the action of browsers, by setting the HTTP headers. The "Refresh" value can be used to specify a delay in seconds before the browser automatically reloads the document. Optionally, you can also specify an alternative URL to load.

For example, the following tag loads the page yours.jsp after 5 seconds.

<META HTTP-EQUIV="Refresh" CONTENT="5;URL=yours.jsp">

A fine tutorial for the META-Tag: HTTP-EQUIV:
http://www.wdvl.com/Authoring/HTML/Head/Meta/HTTP.html
0
 

Expert Comment

by:SweetChastity
ID: 10948298
We work together.  Our pages use a header and footer that contain opening and closing tags for <html> and <body>, this is used to create consistency.  I had a similiar issue and I found solutions to refreshing in meta and body tags which unfortunately we are not able to implement.  I didn't find anything suggesting we could detect when the user had clicked the back button on internet explorer but would be useful to know.
0
Technology Partners: 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:F1stu
ID: 10948556
Hi,

Thanks for all of your help!
Mark's replied helped a lot and it works too.  Thanks! :)

Thank you all very much!
0
 

Expert Comment

by:SCJPGroup
ID: 22657818
i tried the same solution that mark had given...but it does not work for me...i m using struts framework. has this anything to do with this not working.
0
 
LVL 7

Expert Comment

by:mark-b
ID: 22661441
What does not work?  
When you press the back button, does the server not get hit?
What browser are you using?
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 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