• Post Reply Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher forward and the back button  RSS feed

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a question regarding the forward method of request dispatcher. I know the difference between forward and sendredirect but what i'm not able to understand is why the browser behaves quirky when i click on back button. So here is what I have.

1. A page foo.jsp is displayed to the user which has links and a text box and a submit button. The form action is /foo.do (Yes its struts but my question is not related to struts).Its a post request.
2. If the user clicks on the link (form is submitted thro javascript) or the submit button the request is sent to the server and the controller after processing forwards the request to bar.jsp.

Now bar.jsp is displayed and my address bar is still at /foo.do which is correct since its a server side forward. Now when I click on back button in bar.jsp nothing is happening, the same page (bar.jsp) is displayed again, i can't even say its loaded again because the page is not refreshed, its just like the back button is not working and its not sending any request to the server because I monitor the server after clicking on the back button and there are no activity. I don't have cache prevention headers in my response, so I'm assuming the browser has cached bar.jsp and foo.jsp but why is not going back to foo.jsp when i click on back button ?

Second question -> While in bar.jsp if i press F5 i get a pop up saying the information must be resubmitted, now I'm confused if the page is cached why is it requesting the server again ?

Third question --> Will browsers cache post requests by default if we don't have cache control headers in the response ?

I tested in IE 6 and FF 3.

Thanks !
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!