0

So I am running into an issue. I have certain fields that I store within the request from page to page, because each page requires different fields to be populated within a collector that I used cross-page. The problem is the back button.

If I click the link to take my to my login page, the server populates the collector from the request with the appropriate pagename and event name, etc., to allow me to navigate to the login page. (Certain things have to load, so it has to go through a servlet). However, on that page, there are static modules for ads and whatnot, so clicking on one of the ads will take you to a separate, static page that does not require these attributes to access. In Chrome, Safari and FF, if I click the back button after accessing this static page, the browser asks me to reload the request to be able to view the page. In IE8, however, there is no page reload. It just kicks me back to the page, and does not populate the request, and it crashes with my sorry page.

I need to know if there is a way to populate the request on the back button click, and how to do so. Otherwise, my servlet is throwing a null pointer when trying to access the fields because they are all null in the request. Any help would be greatly appreciated. I am not even sure if this is at all possible.

banjokaboom
  • 134
  • 2
  • 16

1 Answers1

0

I guess you are using POST requests to navigate to each page. POST should be used only to send some user action different from page view - login, buying something, changing settings, etc. The browsers require the user to confirm that they want to revisit a page using POST, before that implies state change. See What is the difference between POST and GET?

For simple content pages, where the user does not take action, it's better to use GET requests. Also, it is much more common to use request.getSession() to get and store the user fields on the server side. That is, you only send them once, and then look them up for each request. Look up for tutorials on session tracking in java.

Community
  • 1
  • 1
jmruc
  • 5,350
  • 3
  • 20
  • 38
  • The collector used and the method for navigating pages is what was built into the framework used at the company I work for. It is nothing I can change. But the POST is not sending the user to the static page. It is only used for navigating forms or server side pages to ensure security. So basically these limitations only allow me to look for a solution in which I could populate the request object. – banjokaboom Apr 30 '12 at 16:54
  • @portugusto_programmer Do you have control of whre the `POST` leads you? If yes, it is a good practice to redirect _immediately_ after you process the information - have one servlet for handling, and a page for afterwards. – jmruc Apr 30 '12 at 18:02