Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 33597
  • Last Modified:

back button or refresh page onload

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
F1stu
Asked:
F1stu
1 Solution
 
mark-bCommented:
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
 
ldbkuttyCommented:
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
 
SweetChastityCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
F1stuAuthor Commented:
Hi,

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

Thank you all very much!
0
 
SCJPGroupCommented:
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
 
mark-bCommented:
What does not work?  
When you press the back button, does the server not get hit?
What browser are you using?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now