tags:

views:

472

answers:

2

i am having 2 jsp pages test1.jsp and test2.jsp on test1.jsp i am posting some data and it will redirected to test2.jsp . but from test2.jsp if i clicked ie browser back button then it is showing Webpage has Expired page so how shall i proceed to show test1.jsp on back button click? i am getting this issue in IE browser.

+1  A: 

Have a look at the Redirect After Post pattern.

beny23
+2  A: 

Thus, you're actually not redirecting the request, but just POSTing (and forwarding) the request. You will namely get this error page whenever you tries to get a non-cached POST request from the browser history.

You need to actually redirect the request after POST. This is called the POST-Redirect-GET pattern. Assuming that your webapplication is well designed and that you're using a Servlet to control, preprocess and postprocess requests, then all you need to do is to invoke HttpServletResponse#sendRedirect() instead of RequestDispatcher#forward():

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // Postprocess request parameters here.

    // Finally redirect POST request to a brand new GET request.
    response.sendRedirect("result.jsp");
}

This way the POST request won't be taken in the browser history. Pressing the back button will not get the POST request anymore, but the request which was invoked before it (i.e. the request used to open/view the page with the form).

The only caveat is that the initial request, including all of its parameters and attributes will disappear as well so that you can't make use of them in the result page. If necessary, you can go around this by using the session scope or a querystring/pathinfo in the redirect URL.

This particular "problem" is by the way not MSIE specific. Other browsers will behave the same, they would however only give a bit different error/warning message. In the future, before explicitly pointing MSIE as the root cause, please test with different browsers.

BalusC
FYI : it's working fine in firfox
kedar kamthe