How can I refresh my jsp by clicking "return" button?

Supposed I have two jsps called jsp1.jsp and jsp2.jsp. If I click hte submit in jsp1 it will goto jsp2. If I click the "return" in browser it should go back to jsp1. But what I want is: as it goes back to jsp1 it should refresh it again just like cilcking the refresh button in browser.

How can I do that? Using a js-function?
chenweiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
Stick this in the top of jsp1:

<%
        // Set to expire far in the past.
        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 (use addHeader).
        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
        // Set standard HTTP/1.0 no-cache header.
        response.setHeader("Pragma", "no-cache");
%>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimYatesCommented:
And by the "return", I guess you mean the back button?

Tim
chenweiAuthor Commented:
1.
Yes, what my "return" means "back". :-)

2.
I put all the codes above at the beginning of my jsps. But it seams it works different as by clicking the "refresh" button. Exactly to say, I have a content.jsp and a logoff.jsp. If I click the link "logoff" in content.jsp it will go to the logoff.jsp.

At the beginning of my content.jsp:
...
<%
        response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
        response.setHeader("Pragma", "no-cache");
%>
<%
 if( session.getAttribute( "User" ) != null ){
   response.sendRedirect("./index.jsp");
 }
%>

And at the beginning of my logoff.jsp:
...
<%
        response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
        response.setHeader("Pragma", "no-cache");
%>
<%
         session.removeAttribute("User");
         session.invalidate();
%>
...

What I want is: After I've logoff and if I click "back", it will go to the index.jsp. But it doesn't now. I have to click the "refresh".

3.
What's the difference between
response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
and
response.setHeader("Expires", 0);
?
chenweiAuthor Commented:
Is there any way to catch the action of "back" in jsp?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.